3

There may be two points of intersection between a line and a circle. How can we determine the order of the result given by the macro \tkzInterLC?

Here is a simple example.

\documentclass{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\begin{document}
\begin{tikzpicture}
\tkzDefPoints{2/0/A,-2/0/B,0/1/C,0/0/O}
\tkzDrawPoints(A,B,C,O)
\tkzLabelPoints(A,B,O)
\tkzLabelPoints[above right](C)
\tkzDrawLine(A,B)
\tkzDrawCircle(O,C)
\tkzInterLC(A,B)(O,C) \tkzGetPoints{P}{Q}
\tkzDrawPoints(P,Q)
\tkzLabelPoints(P,Q)
\end{tikzpicture}
\end{document}

How can we know which of (1,0) and (-1,0) goes to P and which goes to Q?

I think similar situation also exists for \tkzInterCC.

4
  • 1
    Welcome to TeX-SE! If you were willing to use "plain" TikZ you could use the sort by key that comes with the intersections library.
    – user121799
    Commented Apr 30, 2019 at 4:46
  • 1
    Welcome to TeX.SX!! Rather than posting code fragments it is better to give a full minimal working example. Currently we have to guess what packages etc you are using and this makes it really hard to help you. A MWE should start with a \documentclass command, have a minimal preamble and then \begin{document}...\end{document}. The code should compile and be as small as possible to demonstrate your problem.
    – user30471
    Commented Apr 30, 2019 at 4:54
  • It seems that O->P->Q are in the clockwise orientation in the diagram. Can anyone confirm?
    – Yuta
    Commented Apr 30, 2019 at 5:39
  • I could not seem to figure out how the order is determined and I made this package Commented Nov 22, 2019 at 17:07

1 Answer 1

1

Just for fun: if you were to consider plain TikZ, then the answer is that you can determine the ordering yourself with the sort by key. The plain TikZ version of your scenario is

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{through,intersections}
\begin{document}
\begin{tikzpicture}
\path (2,0) coordinate (A) (-2,0) coordinate (B)  (0,1) 
coordinate (C) (0,0) coordinate (O);
\node[draw,name path=circ] (Circ) at (O) [circle through={(C)}]{};
\draw[name path=line] (A) -- (B);
\draw[thick,blue,->,name intersections={of=circ and line,sort by=circ}] (intersection-1) -- (intersection-2);
\end{tikzpicture}
\end{document}

enter image description here

The arrow is drawn from the first intersection to the second one. This is because the intersections are ordered according to the circle, and the circle path starts at 0 degrees and runs to 360. Thus, if you rotate the line

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{through,intersections}
\begin{document}
\begin{tikzpicture}
\path (-45:2) coordinate (A) (135:2) coordinate (B)  (0,1) 
coordinate (C) (0,0) coordinate (O);
\node[draw,name path=circ] (Circ) at (O) [circle through={(C)}]{};
\draw[name path=line] (A) -- (B);
\draw[thick,blue,->,name intersections={of=circ and line,sort by=circ}] (intersection-1) -- (intersection-2);
\end{tikzpicture}
\end{document}

you'll get

enter image description here

However, if you sort along a straight line, the results can be unexpected, but you can cure this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .