Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect path segments using intersection segments option from fillbetween library #459

Open
jasperhabicht opened this issue Mar 28, 2023 · 1 comment

Comments

@jasperhabicht
Copy link

jasperhabicht commented Mar 28, 2023

Brief outline of the bug

When using the intersection segments option from the fillbetween library, sometimes the path segments are not calculated correctly, especially when applied to curved paths such as circles or arcs.

I was not able to find a rule for it, but sometimes segments are too large and they would overlap the previous segment even, sometimes the curve is not drawn properly at the end of the segment.

Why is this and how can one circumvent this behaviour?

(PGF Version: 2021/05/15 v3.1.9a)

Minimal working example (MWE)

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{fillbetween, spy}

\begin{document}
\begin{tikzpicture}
    [spy using outlines={circle, magnification=4, size=1cm, connect spies}]

\path[draw=green, name path=CircleA] 
    (120:1) circle[radius=0.25];

\path[draw=magenta, name path=ArcA] 
    (180:1) arc[start angle=180, end angle=0, radius=1];

\draw[cyan, intersection segments={of=CircleA and ArcA, sequence=R3}];

\spy[black!25] on (102.5:1)
    in node at (0,0);


\path[draw=green, name path=CircleB] 
    ([yshift=20pt]120:1) circle[radius=0.25];

\path[draw=magenta, name path=ArcB] 
    ([yshift=20pt]180:1) arc[start angle=180, end angle=0, radius=1];

\draw[yellow, intersection segments={of=CircleB and ArcB, sequence=R2}];

\spy[black!25] on ([yshift=20pt]102.5:1)
    in node at (0,2.5);

\end{tikzpicture}
\end{document}

image

I would expect the yellow segment to start at the intersection of the green circle and the magenta arc. Also, I would expect the cyan path to be exactly drawn over the magenta arc.

@muzimuzhi
Copy link
Member

muzimuzhi commented Mar 31, 2023

Using only tikz library intersection the output looks fine, so I think the problem comes from fillbetween, which is only available if pgfplots is loaded. Hence I'm transferring this issue to https://github.com/pgf-tikz/pgfplots.

An intersection-only example

\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}
\begin{tikzpicture}
  \path[draw=green, name path=CircleA] 
      (120:1) circle[radius=0.25];

  \path[draw=magenta, name path=ArcA] 
      (180:1) arc[start angle=180, end angle=0, radius=1];

  \draw[name intersections={of=CircleA and ArcA, name=x, total=\x}]
    (x-1) -| (x-2);
\end{tikzpicture}
\end{document}

image

@muzimuzhi muzimuzhi transferred this issue from pgf-tikz/pgf Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants