\newpage
\section{Intersections} % (fold)
\label{sec:intersections}

It's an essential tool. For the moment, the classes concerned are lines, circles and ellipses, with the following combinations: line-line; line-circle; circle-circle and line-conic. 
Note that circles form a separate class from conics, which represent parabolas, hyperbolas and ellipses. 
The argument is a pair of objects, in any order.
Results consist of one or two values, either points, boolean \tkzname{false} or underscore |_|. 

\subsection{Line-line} % (fold)
\label{sub:line_line}

The result is of the form: |point| or |false|.

\begin{minipage}{0.6\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
   z.A   = point : new (1,-1)
   z.B   = point : new (4,1)
   z.C   = point : new (2,1)
   z.D   = point : new (4,-2) 
    z.I  = point : new (0,0)
   L.AB  = line : new (z.A,z.B)
   L.CD  = line : new (z.C,z.D)
   x     = intersection (L.AB,L.CD)
   if x  == false then 
   tex.print('error')
   else 
   z.I   = x
   end
}

\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawSegments(A,B C,D)
   \tkzDrawPoints(A,B,C,D,I)
   \tkzLabelPoints(A,B,C,D,I)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\directlua{%
init_elements ()
z.A   = point : new (1,-1)
z.B   = point : new (4,1)
z.C   = point : new (2,1)
z.D   = point : new (4,-2) 
 z.I  = point : new (0,0)
L.AB  = line : new (z.A,z.B)
L.CD  = line : new (z.C,z.D)
x = intersection (L.AB,L.CD)
if x  == false then 
tex.print('error')
else 
z.I   = x
end
}

\begin{tikzpicture}[scale = 2]
   \tkzGetNodes
   \tkzDrawSegments(A,B C,D)
   \tkzDrawPoints(A,B,C,D,I)
   \tkzLabelPoints(A,B,C,D,I)
\end{tikzpicture}
\end{minipage}

Other examples: \ref{sub:altshiller}, \ref{sub:lemoine}, \ref{sub:alternate}
% subsection line_line (end)

\newpage
\subsection{Line-circle} % (fold)
\label{sub:line_circle}
The result is of the form : |point,point| or |false,false|. If the line is tangent to the circle, then the two points are identical. You can ignore one of the points by using the underscore: |_,point| or |point,_|. When the intersection yields two solutions, the order of the points is determined by the argument of |(z.p - z.c)| with |c| center of the circle and |p| point of intersection. The first solution corresponds to the smallest argument (arguments are between 0 and $2\pi$).

\begin{minipage}{0.6\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
   z.A   = point : new (1,-1)
   z.B   = point : new (1,2)
   L.AB  = line : new (z.A,z.B)
   z.O   = point : new (2,1)
   z.D   = point : new (3,1)
   z.E   = point : new (3,2)
   L.AE  = line : new (z.A,z.E)
   C.OD  = circle : new (z.O,z.D)
   z.I,_ = intersection (L.AB,C.OD)
   _,z.K = intersection (C.OD,L.AE)
}

\begin{tikzpicture}
\tkzGetNodes
   \tkzDrawLines(A,B A,E)
   \tkzDrawCircle(O,D)
   \tkzDrawPoints(A,B,O,D,I,K)
   \tkzLabelPoints[left](A,B,O,D,I,K)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\directlua{%
init_elements ()
z.A = point : new (1,-1)
z.B = point : new (1,2)
L.AB = line : new (z.A,z.B)
z.O = point : new (2,1)
z.D = point : new (3,1)
z.E = point : new (3,2)
L.AE = line : new (z.A,z.E)
C.OD = circle : new (z.O,z.D)
z.I,_ = intersection (L.AB,C.OD)
_,z.K = intersection (C.OD,L.AE)
}

\begin{tikzpicture}[ scale = 2]
\tkzGetNodes
\tkzDrawLines[add=.1 and .1](A,B A,E)
\tkzDrawCircle(O,D)
\tkzDrawPoints(A,B,O,D,I,K)
\tkzLabelPoints[left](A,B,O,D,I,K)
\end{tikzpicture}
\hfill
\end{minipage}

Other examples: \ref{sub:altshiller}
% subsection line_circle (end)

\newpage
\subsection{Circle-circle} % (fold)
\label{sub:circle_circle}

The result is of the form : |point,point| or |false,false|. If the circles are  tangent, then the two points are identical. You can ignore one of the points by using the underscore: |_ , point| or |point , _|. As for the intersection of a line and a circle, consider the argument of |z.p-z.c|  with |c| center of the first circle and |p| point of intersection. The first solution corresponds to the smallest argument (arguments are between 0 and $2\pi$).

\begin{minipage}{0.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
   z.A      = point : new (1,1)
   z.B      = point : new (2,2)
   z.C      = point : new (3,3)
   z.D      = point : new (3,0)
   C.AB     = circle : new (z.A,z.B)
   C.CB     = circle : new (z.C,z.B)
   z.I,_    = intersection (C.AB,C.CB)
   C.DC     = circle : new (z.D,z.C)
   z.J,z.K  = intersection (C.DC,C.CB)
}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawCircles(A,B C,B D,C)
   \tkzDrawPoints(A,I,C,D,J,K)
   \tkzLabelPoints(A,I,C,D,J,K)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\directlua{%
init_elements ()
z.A = point : new (1,1)
z.B = point : new (2,2)
z.C = point : new (3,3)
z.D = point : new (3,0)
C.AB = circle : new (z.A,z.B)
C.CB = circle : new (z.C,z.B)
z.I,_ = intersection (C.AB,C.CB)
C.DC = circle : new (z.D,z.C)
 z.J,z.K = intersection (C.DC,C.CB)
}

\begin{tikzpicture}
\tkzGetNodes
\tkzDrawCircles(A,B C,B D,C)
\tkzDrawPoints(A,I,C,D,J,K)
\tkzLabelPoints(A,I,C,D,J,K)
\end{tikzpicture}
\end{minipage}

Other examples: \ref{sub:altshiller}, \ref{sub:the_figure_pappus_circle}
% subsection circle_circle (end)

\newpage
\subsection{Line-conic} % (fold)
\label{sub:line_conic}
The following example is complex, but it shows the possibilities of Lua.
The designation of intersection points is a little more complicated than the previous one, as the argument characterizing the major axis must be taken into account.  The principle is the same, but this argument must be subtracted. In concrete terms, you need to consider the slopes of the lines formed by the center of the ellipse and the points of intersection, and the slope of the major axis.
\vspace{1em}

\begin{minipage}{0.5\textwidth}
\begin{Verbatim}
\directlua{%
 init_elements ()
 z.a      = point: new (5 , 2)
 z.b      = point: new (-4 , 0)
 L.ab     = line : new (z.a,z.b)
 z.c      = L.ab.mid
 z.v      = L.ab: point (-.2)
 local a  = length (z.c,z.v)
 local c  = .5 * length(z.a, z.b)
 local e  = c / a
 z.K      = L.ab : report (a^2 / c, z.c)
 z.Kp     = (z.K-z.a) : orthogonal(2): at (z.K)
 L.dir    = line : new (z.K,z.Kp)
 EL       = conic: new (z.b,L.dir,e)
 curve    = EL : points (0,1,50)
 z.m      = point: new (2 , 4)
 z.n      = point: new (4 , 4)
 L.mn     = line : new (z.m,z.n)
 z.r,z.s  = intersection (EL,L.mn)
}
\begin{tikzpicture}[scale =.5]
   \tkzGetNodes
   \tkzDrawLines[red](a,b r,s)
   \tkzDrawSegments(c,r c,s)
   \tkzDrawPoints(a,b,c,r,s)
   \tkzLabelPoints(a,b,c,r,s)
   \tkzDrawCoordinates[smooth,red](curve)
   \tkzFillAngles[green!30,opacity=.4](v,c,s)
   \tkzFillAngles[green!80,opacity=.4](v,c,r)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\directlua{%
 init_elements ()
 z.a      = point: new (5 , 2)
 z.b      = point: new (-4 , 0)
 L.ab     = line : new (z.a,z.b)
 z.c      = L.ab.mid
 z.v      = L.ab: point (-.2)
 local a  = length (z.c,z.v)
 local c  = .5 * length(z.a, z.b)
 local e  = c / a
 z.K      = L.ab : report (a^2 / c, z.c)
 z.Kp     = (z.K-z.a) : orthogonal(2): at (z.K)
 L.dir    = line : new (z.K,z.Kp)
 EL       = conic: new (z.b,L.dir,e)
 curve    = EL : points (0,1,50)
 z.m      = point: new (2 , 4)
 z.n      = point: new (4 , 4)
 L.mn     = line : new (z.m,z.n)
 z.r,z.s  = intersection (EL,L.mn)
}


\begin{center}
\begin{tikzpicture}[scale =.5]
   \tkzGetNodes
   \tkzDrawLines[red](a,b r,s)
   \tkzDrawSegments(c,r c,s)
   \tkzDrawPoints(a,b,c,r,s)
   \tkzLabelPoints(a,b,c,r,s)
   \tkzDrawCoordinates[smooth,red](curve)
   \tkzFillAngles[green!30,opacity=.4](v,c,s)
   \tkzFillAngles[green!80,opacity=.4](v,c,r)
\end{tikzpicture}
\end{center}
\end{minipage}

Other examples:  \ref{sub:hexagram}

\subsubsection{Intersection all subtypes of conics} % (fold)
\label{ssub:intersection_all_subtypes_of_conics}

\begin{Verbatim}
\directlua{
 z.A         = point : new ( 0 , 0 )
 z.B         = point : new ( 4 , -2 )
 L.dir       = line  : new (z.A,z.B)
 z.F         = point : new ( 2 , 2)
 CO1         = conic : new(z.F,L.dir,.8)
 CO2         = conic : new(z.F,L.dir, 1)
 CO3         = conic : new(z.F,L.dir, 1.2)
 curve1      = CO1 : points ( 0,1,50)
 curve2      = CO2 : points (-5,5,50)
 curve3      = CO3 : points (-5,5,50)
 z.K         = CO1.K
 z.u,z.v     = get_points(CO1.major_axis)
 z.x         = L.dir : report (-4,z.K)
 z.y         = L.dir : report ( 4,z.K)
 z.r         = point : new ( 0 , 4 )
 z.s         = point : new ( 4 , 1 )
 L.rs        = line  : new (z.r,z.s)
 z.u_1,z.u_2 = intersection (L.rs,CO1)
 z.v_1,z.v_2 = intersection (L.rs,CO2)
 z.w_1,z.w_2 = intersection (L.rs,CO3)
}
\begin{tikzpicture}
 \tkzGetNodes
 \tkzDrawCoordinates[smooth](curve1)
 \tkzDrawCoordinates[smooth](curve2)
 \tkzDrawCoordinates[smooth](curve3)
 \tkzDrawLines[add =.5 and .5](r,s u,v)
 \tkzDrawLines(x,y)
 \tkzDrawPoints[red](u_1,u_2,v_2,v_1,w_1,w_2)
\end{tikzpicture}
\end{Verbatim}
\directlua{
z.A         = point : new ( 0 , 0 )
z.B         = point : new ( 4 , -2 )
L.dir       = line  : new (z.A,z.B)
z.F         = point : new ( 2 , 2)
CO1         = conic : new(z.F,L.dir,.8)
CO2         = conic : new(z.F,L.dir, 1)
CO3         = conic : new(z.F,L.dir, 1.2)
curve1      = CO1 : points ( 0,1,50)
curve2      = CO2 : points (-5,5,50)
curve3      = CO3 : points (-5,5,50)
z.K         = CO1.K
z.u,z.v     = get_points(CO1.major_axis)
z.x         = L.dir : report (-4,z.K)
z.y         = L.dir : report ( 4,z.K)
z.r         = point : new ( 0 , 4 )
z.s         = point : new ( 4 , 1 )
L.rs        = line  : new (z.r,z.s)
z.u_1,z.u_2 = intersection (L.rs,CO1)
z.v_1,z.v_2 = intersection (L.rs,CO2)
z.w_1,z.w_2 = intersection (L.rs,CO3)
}

\begin{center}
  \begin{tikzpicture}[scale =.75]
  \tkzGetNodes
  \tkzDrawCoordinates[smooth](curve1)
  \tkzDrawCoordinates[smooth](curve2)
  \tkzDrawCoordinates[smooth](curve3)
  \tkzDrawLines[add =.5 and .5](r,s u,v)
  \tkzDrawLines(x,y)
  \tkzDrawPoints[red](u_1,u_2,v_2,v_1,w_1,w_2)
  \end{tikzpicture}
\end{center}


% subsubsection intersection_all_subtypes_of_conics (end)

% subsection line_conic (end)
% section intersections (end)