Skip to content

Commit

Permalink
Fix sorting of intersections #480
Browse files Browse the repository at this point in the history
CAVEAT: Breaking change!

The order of intersection will change if you are using the
\pgfintersectionsortby... commands or the "sort by=" key in TikZ.
  • Loading branch information
hmenke committed Nov 29, 2019
1 parent 0092d3a commit acd2ca3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tex/generic/pgf/libraries/pgflibraryintersections.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -361,23 +361,30 @@
\global\advance\pgf@intersect@solutions by1\relax%
\expandafter\global\expandafter\let\csname pgfpoint@g@intersect@solution@\the\pgf@intersect@solutions\endcsname=\pgf@intersect@solution@candidate
\ifpgf@intersect@sort%
% save coordinates of the intersection
\pgf@process{\pgf@intersect@solution@candidate}%
\pgf@xc=\pgf@x%
\pgf@yc=\pgf@y%
% determine length of path
\pgf@process{\pgfpointdiff{\pgfpoint@intersect@start@a}{\pgfpoint@intersect@end@a}}%
\edef\pgf@marshal{%
\noexpand\pgfmathveclen@{\pgfmath@tonumber{\pgf@xa}}{\pgfmath@tonumber{\pgf@ya}}%
\noexpand\pgfmathveclen@{\pgfmath@tonumber{\pgf@x}}{\pgfmath@tonumber{\pgf@y}}%
}%
\pgf@marshal%
\let\pgf@intersect@length@a=\pgfmathresult%
% determine distance of intersection from start
\pgf@process{\pgfpointdiff{\pgfpoint@intersect@start@a}{\pgfqpoint{\pgf@xc}{\pgf@yc}}}%
\edef\pgf@marshal{%
\noexpand\pgfmathveclen@{\pgfmath@tonumber{\pgf@x}}{\pgfmath@tonumber{\pgf@y}}%
}%
\pgf@marshal%
% scale the distance to the path length (path time)
\pgfmathdivide@{\pgfmathresult}{\pgf@intersect@length@a}%
\pgf@x=\pgfmathresult pt\relax%
% advance by the path segment (see definition of \pgf@intersection@store@properties)
\advance\pgf@x by\pgf@intersect@time@offset pt\relax%
\edef\pgf@intersect@time@a{\pgfmath@tonumber{\pgf@x}}%
% save numbered
\expandafter\global\expandafter\let\csname pgf@g@intersect@solution@\the\pgf@intersect@solutions @time@a\endcsname=
\pgf@intersect@time@a
\else
Expand Down

0 comments on commit acd2ca3

Please sign in to comment.