pgf-tikz / pgf

A Portable Graphic Format for TeX
https://pgf-tikz.github.io/
1.1k stars 105 forks source link

Path transformations cause intersections to be computed incorrectly #929

Closed sergiud closed 3 years ago

sergiud commented 3 years ago

As of 3.1.6, path intersections are computed incorrectly if path coordinates are e.g., scaled. The regression was likely caused by the fix for issue #889 in commit 908db0011cc96b4092b45de7d432e3ead32f4323.

Minimal working example (MWE)

\documentclass[tikz]{standalone}

\usetikzlibrary{calc}
\usetikzlibrary{intersections}

\begin{document}

\begin{tikzpicture}
[
  % NOTE Comment the following line to obtain the expected result
  every path/.style={scale=1.25},
  declare function={
    angle=22.5;
  },
]
  \draw[densely dotted] (0,0) -- +(angle:0.5) coordinate (A);
  \draw (A)
    --
    %node[sloped,below] {\(l_1\)}
    +(angle:1.2)
    coordinate (B)
    ;

  \draw
    ($(B)+(2.25,0)$) coordinate (C)
    --
    +(-22.5:1) coordinate (D)
    ;
  \draw[densely dotted] (D) -- +(-angle:.5) coordinate (E);

  \path[name path=BC] (B) -- (angle:5) coordinate (AB ext);
  \path[name path=CD] (C) -- +(-angle:-3) coordinate (CD ext);

  \path[name intersections={of=BC and CD,by=inter}];

  % The intersection of extended lines
  \draw[mark=x,very thick,scale=1.5] plot coordinates {(inter)};
\end{tikzpicture}

\end{document}

\end{document}

mwe-1

Without scaling, the intersection given by the cross is placed correctly:

mwe-after-1

hmenke commented 3 years ago

Thanks, fixed in https://github.com/pgf-tikz/pgf/commit/0aac8f6affcbab3253b8b9bf2435b497bc386b53 by reverting the offending commit https://github.com/pgf-tikz/pgf/commit/908db0011cc96b4092b45de7d432e3ead32f4323