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

[intersections] "Sort by" resulting in wrong order of intersections #480

Closed
pgf-tikz-bot opened this issue May 2, 2018 · 1 comment
Closed

Comments

@pgf-tikz-bot
Copy link

pgf-tikz-bot commented May 2, 2018

Migrated from SourceForge
Author: icyd
Timestamp: 2018-05-02 09:51:08.169000

Using the following MWE, the direction of the blue arrow is opposite to the black one:

\documentclass{standalone}    
\usepackage{tikz}  
\usetikzlibrary{intersections}
\begin{document}  
\begin{tikzpicture}
    \draw [name path=base] (-1,-1) rectangle (1,1);
    \draw [->, name path=line] (0.5,-2) -- (1.8,2);
    \draw [color=blue, thick, ->, name intersections={of=line and base, sort by=line}] (intersection-1) -- (intersection-2);
\end{tikzpicture}  
\end{document}
@hmenke hmenke removed the open label Apr 2, 2019
@hmenke hmenke added this to the 3.1.5 milestone Nov 5, 2019
@hmenke
Copy link
Member

hmenke commented Nov 29, 2019

Pure PGF reproducer.

\documentclass{standalone}    
\usepackage{tikz}  
\usepgflibrary{intersections}
\begin{document}  
\begin{pgfpicture}
  \pgfpathrectangle{\pgfqpoint{-1cm}{-1cm}}{\pgfqpoint{2cm}{2cm}}
  \pgfusepath{stroke}
  \pgfsetarrowsend{>}
  \pgfpathmoveto{\pgfqpoint{0.5cm}{-2cm}}
  \pgfpathlineto{\pgfqpoint{1.8cm}{2cm}}
  \pgfusepath{stroke}

  \pgfintersectionsortbyfirstpath
  \pgfintersectionofpaths{
    \pgfpathmoveto{\pgfqpoint{0.5cm}{-2cm}}
    \pgfpathlineto{\pgfqpoint{1.8cm}{2cm}}
  }{
    \pgfpathrectangle{\pgfqpoint{-1cm}{-1cm}}{\pgfqpoint{2cm}{2cm}}
  }

  \color{blue}
  \pgfsetarrowsend{>}
  \pgfpathmoveto{\pgfpointintersectionsolution{1}}
  \pgfpathlineto{\pgfpointintersectionsolution{2}}
  \pgfusepath{stroke}
\end{pgfpicture}  
\end{document}

hmenke added a commit to hmenke/pgf that referenced this issue Nov 29, 2019
CAVEAT: Breaking change!

The order of intersection will change if you are using the
\pgfintersectionsortby... commands or the "sort by=" key in TikZ.
@hmenke hmenke closed this as completed Nov 30, 2019
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