\newpage

\section{Examples} % (fold)
\label{sec:examples}

\subsection{Length transfer} % (fold)
\label{sub:report_de_distance}

Use of |north and east| functions linked to points, to transfer lengths, Refer to (\ref{sub:length_of_a_segment})

\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
  z.A   = point : new ( 0 , 0 )
  z.B   = point : new ( 3 , 0 )
  L.AB  = line : new ( z.A , z.B )
  T.ABC = L.AB : sublime ()
  z.C   = T.ABC.pc
  z.D   = z.B: north (length(z.B,z.C))
  z.E   = z.B: east (L.AB.length)
  z.M   = L.AB.mid
  z.F   = z.E : north (length(z.C,z.M))
}
\begin{tikzpicture}[gridded,scale=.75]
   \tkzGetNodes
   \tkzDrawPolygons(A,B,C) 
   \tkzDrawSegments[gray,dashed](B,D B,E E,F C,M)
   \tkzDrawPoints(A,...,F)
   \tkzLabelPoints(A,B,E,M)
   \tkzLabelPoints[above right](C,D,F)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{%
init_elements ()
   z.A = point : new ( 0 , 0 )
   z.B = point : new ( 3 , 0 )
   L.AB = line : new ( z.A , z.B )
   T.ABC =   L.AB : sublime ()
   z.C = T.ABC.pc
   z.D = z.B: north (length(z.B,z.C))
   z.E = z.B: east (L.AB.length)
   z.M = L.AB.mid
   z.F = z.E : north (length(z.C,z.M))
}

\begin{center}
  \begin{tikzpicture}[gridded,scale=.75]
     \tkzGetNodes
     \tkzDrawPolygons(A,B,C) 
     \tkzDrawSegments[gray,dashed](B,D B,E E,F C,M)
     \tkzDrawPoints(A,...,F)
     \tkzLabelPoints(A,B,E,M)
     \tkzLabelPoints[above right](C,D,F)
  \end{tikzpicture}
\end{center}

\end{minipage}
% subsection report_de_distance (end)

\subsection{Apollonius circles of a triangle} % (fold)
\label{sub:apollonius_circles_of_a_triangle}

\emph{The three Apollonius circles of a (non-equilateral) triangle meet at exactly two points.
}

Proof:

Let $ABC$ be a non-equilateral triangle, say with $AB \not =AC$. By definition, we have directly that if a point belongs to two of the circles, then it belongs to the third. Indeed, if

$\dfrac{MB}{MC} = \dfrac{AB}{AC}$ and $\dfrac{MA}{MB} = \dfrac{CA}{CB}$  then  $\dfrac{MA}{MC} = \dfrac{BA}{BC}$

However,  the circles are neither tangent nor disjoint if $AB \not =AC$ .

The three Apollonius circles are coaxal. 
\vspace{12pt}


\begin{Verbatim}
  \directlua{%
  z.A = point : new (0,0)
  z.B = point : new (5,0)
  z.C = point : new (3.5,2)
  T = triangle : new (z.A,z.B,z.C)
  z.O = T.circumcenter
  C.AB = T.ab : apollonius(T.b/T.a)
  z.w1,z.t1 = get_points(C.AB)
  C.BC = T.bc : apollonius(T.c/T.b)
  z.w2,z.t2 = get_points(C.BC)
  C.AC = T.ca : apollonius(T.a/T.c)
  z.w3,z.t3 = get_points(C.AC)
  }
  \begin{tikzpicture}[scale=.5]
   \tkzGetNodes
   \tkzDrawPolygon(A,B,C)
   \tkzDrawCircle[purple](O,A)
   \tkzDrawCircles[cyan](w1,t1 w2,t2 w3,t3)
   \tkzDrawLine(w1,w2)
   \tkzDrawPoints(A,B,C,w1,w2,w3)
   \tkzLabelPoints(A,B,w1,w2,w3)
    \tkzLabelPoints[above](C)
  \end{tikzpicture}
\end{Verbatim}

\directlua{%
z.A = point : new (0,0)
z.B = point : new (5,0)
z.C = point : new (3.5,2)
T = triangle : new (z.A,z.B,z.C)
z.O = T.circumcenter
C.AB = T.ab : apollonius(T.b/T.a)
z.w1,z.t1 = get_points(C.AB)
C.BC = T.bc : apollonius(T.c/T.b)
z.w2,z.t2 = get_points(C.BC)
C.AC = T.ca : apollonius(T.a/T.c)
z.w3,z.t3 = get_points(C.AC)
}
\begin{center}
  \begin{tikzpicture}[scale=.5]
   \tkzGetNodes
   \tkzDrawPolygon(A,B,C)
   \tkzDrawCircle[purple](O,A)
   \tkzDrawCircles[cyan](w1,t1 w2,t2 w3,t3)
   \tkzDrawLine(w1,w2)
   \tkzDrawPoints(A,B,C,w1,w2,w3)
   \tkzLabelPoints(A,B,w1,w2,w3)
    \tkzLabelPoints[above](C)
  \end{tikzpicture}
\end{center}

% subsection apollonius_circles_of_a_triangle (end)

\subsection{D'Alembert 1} % (fold)
\label{sub:d_alembert_1}

\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\begin{Verbatim}
\directlua{%
init_elements ()
  z.A  = point : new (0,0)
  z.a  = point : new (4,0)
  z.B  = point : new (7,-1)
  z.b  = point : new (5.5,-1)
  z.C  = point : new (5,-4)
  z.c  = point : new (4.25,-4)
  C.Aa = circle : new (z.A,z.a)
  C.Bb = circle : new (z.B,z.b)
  C.Cc = circle : new (z.C,z.c)
  z.I  = C.Aa : external_similitude (C.Bb)
  z.J  = C.Aa : external_similitude (C.Cc)
  z.K  = C.Cc : external_similitude (C.Bb)
  z.Ip = C.Aa : internal_similitude (C.Bb)
  z.Jp = C.Aa : internal_similitude (C.Cc)
  z.Kp = C.Cc : internal_similitude (C.Bb)
}
\begin{tikzpicture}[rotate=-60]
  \tkzGetNodes
  \tkzDrawCircles(A,a B,b C,c)
  \tkzDrawPoints(A,B,C,I,J,K,I',J',K')
  \tkzDrawSegments[new](I,K A,I A,J B,I B,K C,J C,K)
  \tkzDrawSegments[purple](I,J' I',J I',K)
  \tkzLabelPoints(I,J,K,I',J',K')
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\directlua{%
init_elements ()
z.A = point : new (0,0)
z.a = point : new (4,0)
z.B = point : new (7,-1)
z.b = point : new (5.5,-1)
z.C = point : new (5,-4)
z.c = point : new (4.25,-4)
C.Aa    = circle :    new (z.A,z.a)
C.Bb    = circle :    new (z.B,z.b)
C.Cc    = circle :    new (z.C,z.c)
z.I = C.Aa : external_similitude (C.Bb)
z.J = C.Aa : external_similitude (C.Cc)
z.K = C.Cc : external_similitude (C.Bb)
z.Ip    = C.Aa : internal_similitude (C.Bb)
z.Jp    = C.Aa : internal_similitude (C.Cc)
z.Kp    = C.Cc : internal_similitude (C.Bb)
}
  
\begin{center}
  \begin{tikzpicture}[rotate=30,scale=.5]
     \tkzGetNodes
     \tkzDrawCircles(A,a B,b C,c)
     \tkzDrawPoints(A,B,C,I,J,K,I',J',K')
     \tkzDrawSegments[new](I,K A,I A,J B,I B,K C,J C,K)
     \tkzDrawSegments[purple](I,J' I',J I',K)
     \tkzLabelPoints(I,J,K,I',J',K')
  \end{tikzpicture}
\end{center}

\end{minipage}
% subsection d_alembert_1 (end)

\subsection{D'Alembert 2} % (fold)
\label{sub:d_alembert_2}

\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\begin{Verbatim}
\directlua{%
 init_elements ()
 z.A     = point : new (0,0)
 z.a     = point : new (5,0)
 z.B     = point : new (7,-1)
 z.b     = point : new (3,-1)
 z.C     = point : new (5,-4)
 z.c     = point : new (2,-4)
 C.Aa    = circle :    new (z.A,z.a)
 C.Bb    = circle :    new (z.B,z.b)
 C.Cc    = circle :    new (z.C,z.c)
 z.i,z.j = get_points (C.Aa : radical_axis (C.Bb))
 z.k,z.l = get_points (C.Aa : radical_axis (C.Cc))
 z.m,z.n = get_points (C.Bb : radical_axis (C.Cc))
}
\begin{tikzpicture}[scale = .5]
   \tkzGetNodes
   \tkzDrawCircles(A,a B,b C,c)
   \tkzDrawLines[new](i,j k,l m,n)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\directlua{%
   init_elements ()
   z.A     = point : new (0,0)
   z.a     = point : new (5,0)
   z.B     = point : new (7,-1)
   z.b     = point : new (3,-1)
   z.C     = point : new (5,-4)
   z.c     = point : new (2,-4)
   C.Aa    = circle :    new (z.A,z.a)
   C.Bb    = circle :    new (z.B,z.b)
   C.Cc    = circle :    new (z.C,z.c)
   z.i,z.j = get_points (C.Aa : radical_axis (C.Bb))
   z.k,z.l = get_points (C.Aa : radical_axis (C.Cc))
   z.m,z.n = get_points (C.Bb : radical_axis (C.Cc))
}

\begin{center}
  \begin{tikzpicture}[scale = .5]
  \tkzGetNodes
  \tkzDrawCircles(A,a B,b C,c)
  \tkzDrawLines[new](i,j k,l m,n)
  \end{tikzpicture}
\end{center}

\end{minipage}
% subsection d_alembert_2 (end)

\subsection{Altshiller} % (fold)
\label{sub:altshiller}

\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
 init_elements ()
 z.P   = point : new (0,0)
 z.Q   = point : new (5,0)
 z.I   = point : new (3,2)
 C.QI  = circle :    new (z.Q,z.I)
 C.PE  = C.QI : orthogonal_from (z.P)
 z.E   = C.PE.through
 C.QE  = circle :    new (z.Q,z.E)
 _,z.F = intersection (C.PE,C.QE)
 z.A   = C.PE: point (1/9)
 L.AE  = line : new (z.A,z.E)
 _,z.C = intersection (L.AE,C.QE)
 L.AF  = line : new (z.A,z.F)
 L.CQ  = line : new (z.C,z.Q)
 z.D   = intersection (L.AF,L.CQ)
}
\begin{tikzpicture}
 \tkzGetNodes
 \tkzDrawCircles(P,E Q,E)
 \tkzDrawLines[add=0 and 1](P,Q)
 \tkzDrawLines[add=0 and 2](A,E)
 \tkzDrawSegments(P,E E,F F,C A,F C,D)
 \tkzDrawPoints(P,Q,E,F,A,C,D)
 \tkzLabelPoints(P,Q,E,F,A,C,D)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{%
init_elements ()
z.P  = point : new (0,0)
z.Q  = point : new (5,0)
z.I  = point : new (3,2)
C.QI = circle :    new (z.Q,z.I)
C.PE = C.QI : orthogonal_from (z.P)
z.E  = C.PE.through
C.QE = circle :    new (z.Q,z.E)
_,z.F = intersection (C.PE,C.QE)
z.A  = C.PE: point (1/9)
L.AE = line : new (z.A,z.E)
_,z.C    = intersection (L.AE,C.QE)
L.AF = line : new (z.A,z.F)
L.CQ = line : new (z.C,z.Q)
z.D  = intersection (L.AF,L.CQ)
}
   \begin{center}
     \begin{tikzpicture}[scale =.5]
     \tkzGetNodes
     \tkzDrawCircles(P,E Q,E)
     \tkzDrawLines[add=0 and 1](P,Q)
     \tkzDrawLines[add=0 and 2](A,E)
     \tkzDrawSegments(P,E E,F F,C A,F C,D)
     \tkzDrawPoints(P,Q,E,F,A,C,D)
     \tkzLabelPoints(P,Q,E,F,A,C,D)
     \end{tikzpicture}
   \end{center}
\end{minipage}
%subsection altshiller (end)

\subsection{Lemoine} % (fold)
\label{sub:lemoine}

\begin{minipage}{.4\textwidth}
\begin{Verbatim}
\directlua{%
 init_elements ()
 z.A   = point: new (1,0)
 z.B   = point: new (5,2)
 z.C   = point: new (1.2,2)
 T     = triangle: new(z.A,z.B,z.C)
 z.O   = T.circumcenter
 C.OA  = circle: new (z.O,z.A)
 L.tA  = C.OA: tangent_at (z.A)
 L.tB  = C.OA: tangent_at (z.B)
 L.tC  = C.OA: tangent_at (z.C)
 z.P   = intersection (L.tA,T.bc)
 z.Q   = intersection (L.tB,T.ca)
 z.R   = intersection (L.tC,T.ab)
}
\begin{tikzpicture}[scale = 1.25]
 \tkzGetNodes  
 \tkzDrawPolygon[teal](A,B,C)
 \tkzDrawCircle(O,A)
 \tkzDrawPoints(A,B,C,P,Q,R)
 \tkzLabelPoints(A,B,C,P,Q,R)
 \tkzDrawLine[blue](Q,R)
 \tkzDrawLines[red](A,P B,Q R,C)
 \tkzDrawSegments(A,R C,P C,Q)
\end{tikzpicture}
\end{Verbatim}

\end{minipage}
\begin{minipage}{.6\textwidth}
\directlua{%
init_elements ()
z.A   = point: new (1,0)
z.B   = point: new (5,2)
z.C   = point: new (1.2,2)
T     = triangle: new(z.A,z.B,z.C)
z.O   = T.circumcenter
C.OA  = circle: new (z.O,z.A)
L.tA  = C.OA: tangent_at (z.A)
L.tB  = C.OA: tangent_at (z.B)
L.tC  = C.OA: tangent_at (z.C)
z.R   = intersection (L.tC,T.ab)
z.P   = intersection (L.tA,T.bc)
z.Q   = intersection (L.tB,T.ca)
}

\begin{center}
  \begin{tikzpicture}[rotate=90,scale = .75]
  \tkzGetNodes  
  \tkzDrawPolygon[teal](A,B,C)
  \tkzDrawCircle(O,A)
  \tkzDrawPoints(A,B,C,P,Q,R)
  \tkzDrawLine[blue](Q,R)
  \tkzDrawLines[red](A,P B,Q R,C)
  \tkzDrawSegments(A,R C,P C,Q)
  \tkzLabelPoints(A,B,C,P,Q,R)
  \end{tikzpicture}
\end{center}

\end{minipage}
%\caption{Lemoine line}
% subsection lemoine (end)


\subsection{Alternate} % (fold)
\label{sub:alternate}
\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\begin{Verbatim}
\directlua{%
 init_elements ()
 z.A  = point: new (0 , 0)
 z.B  = point: new (6 , 0)
 z.C  = point: new (1 , 5)
 T    = triangle: new (z.A,z.B,z.C)
 z.I  = T.incenter
 L.AI = line: new (z.A,z.I) 
 z.D  = intersection (L.AI,T.bc)
 L.LLC= T.ab: ll_from (z.C)
 z.E  = intersection (L.AI,L.LLC)
}
\begin{tikzpicture}
 \tkzGetNodes
 \tkzDrawPolygon(A,B,C)
 \tkzDrawLine[purple](C,E)
 \tkzDrawSegment[purple](A,E)
 \tkzFillAngles[purple!30,opacity=.4](B,A,C C,E,D)
 \tkzMarkAngles[mark=|](B,A,D D,A,C C,E,D)
 \tkzDrawPoints(A,...,E)
 \tkzLabelPoints(A,B)
 \tkzLabelPoints[above](C,D,E)
 \tkzMarkSegments(A,C C,E)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\directlua{%
init_elements ()
z.A  = point: new (0 , 0)
z.B  = point: new (6 , 0)
z.C  = point: new (1 , 5)
T    = triangle: new (z.A,z.B,z.C)
z.I  = T.incenter
L.AI = line: new (z.A,z.I) 
z.D  = intersection (L.AI,T.bc)
L.LLC    = T.ab: ll_from (z.C)
z.E  = intersection (L.AI,L.LLC)
}
\begin{center}
  \begin{tikzpicture}[scale=.75]
  \tkzGetNodes
  \tkzDrawPolygon(A,B,C)
  \tkzDrawLine[purple](C,E)
  \tkzDrawSegment[purple](A,E)
  \tkzFillAngles[purple!30,opacity=.4](B,A,C C,E,D)
  \tkzMarkAngles[mark=|](B,A,D D,A,C C,E,D)
  \tkzDrawPoints(A,...,E)
  \tkzLabelPoints[above](C,D,E)
  \tkzMarkSegments(A,C C,E)
  \tkzLabelPoints(A,B)
  \end{tikzpicture}
\end{center}
\end{minipage}
% subsection alternate (end)

\subsection{Method \Imeth{circle}{common tangent}: orthogonality} % (fold)
\label{sub:common_tangent_orthogonality}
For two circles  to be orthogonal, it is necessary and sufficient for a secant  passing through one of their common points to be seen from the other common point at a right angle.

\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
 init_elements ()
 z.A   = point : new ( 0  , 0  )
 z.B   = point : new ( 4  , 2  )
 L.AB  = line : new ( z.A , z.B )
 z.a   = point : new ( 1 , 2 )
 C.Aa  = circle : new (z.A,z.a)
 C.BC  = C.Aa : orthogonal_from (z.B)
 z.C,
 z.D   = intersection (C.Aa,C.BC)
 C.AC  = circle : new (z.A,z.C)
 z.T,
 z.Tp  = C.AC : common_tangent (C.BC)
 L.TTp = line : new (z.T,z.Tp)
 z.M   = C.AC : point (0.45)
 L.MC  =line : new (z.M,z.C)
 z.Mp  = intersection (L.MC, C.BC) 
 L.mm  = L.TTp : ll_from (z.C)
 _,z.M = intersection (L.mm, C.AC)
 z.Mp  = intersection (L.mm, C.BC)
}  
\begin{tikzpicture}
 \tkzGetNodes
 \tkzDrawCircles(A,C B,C)
 \tkzDrawSegments(M,M' A,C B,C A,B)
 \tkzDrawSegments[gray](D,M D,M' T,T')
 \tkzDrawPoints(A,B,C,D,M,M',T,T')
 \tkzLabelPoints(A,B,D,M)
 \tkzLabelPoints[above](C,M',T,T')
 \tkzMarkRightAngles(M',D,M A,C,B)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
  \directlua{%
  init_elements ()
  z.A   = point : new ( 0  , 0  )
  z.B   = point : new ( 4  , 2  )
  L.AB = line : new ( z.A , z.B )
  z.a   = point : new ( 1 , 2 )
  C.Aa  = circle : new (z.A,z.a)
  C.BC = C.Aa : orthogonal_from (z.B)
  z.C,z.D = intersection (C.Aa,C.BC)
  C.AC  = circle : new (z.A,z.C)
  z.T,z.Tp = C.AC : common_tangent (C.BC)
  L.TTp = line : new (z.T,z.Tp)
  z.M   = C.AC : point (0.45)
  L.MC  =line : new (z.M,z.C)
  z.Mp  = intersection (L.MC, C.BC) 
  L.mm = L.TTp : ll_from (z.C)
  _,z.M = intersection (L.mm, C.AC)
  z.Mp = intersection (L.mm, C.BC)
  }
    
  \begin{center}
  \begin{tikzpicture}[scale=.75]
     \tkzGetNodes
     \tkzDrawCircles(A,C B,C)
     \tkzDrawSegments(M,M' A,C B,C A,B)
     \tkzDrawSegments[gray](D,M D,M' T,T')
     \tkzDrawPoints(A,B,C,D,M,M',T,T')
     \tkzLabelPoints(A,B,D,M)
     \tkzLabelPoints[above](C,M',T,T')
     \tkzMarkRightAngles(M',D,M A,C,B)
  \end{tikzpicture}
  \end{center}
\end{minipage}

% subsection common_tangent_orthogonality (end)


\subsection{Apollonius circle} % (fold)
\label{sub:apollonius_circle}

\directlua{%
init_elements ()
z.A      = point: new (0 , 0)
z.B      = point: new (6 , 0)
z.M      = point: new (5 , 3)
T.MAB    = triangle : new (z.M,z.A,z.B)
L.bis    = T.MAB : bisector ()
z.C      = L.bis.pb
L.bisext = T.MAB : bisector_ext ()
z.D      = intersection (T.MAB.bc, L.bisext)
L.CD     = line: new (z.C,z.D)
z.O      = L.CD.mid
L.AM     = T.MAB.ab
z.E      = z.M : symmetry (z.A)
}

\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
   z.A      = point: new (0 , 0)
   z.B      = point: new (6 , 0)
   z.M      = point: new (5 , 3)
   T.MAB    = triangle : new (z.M,z.A,z.B)
   L.bis    = T.MAB : bisector ()
   z.C      = L.bis.pb
   L.bisext = T.MAB : bisector_ext ()
   z.D      = intersection (T.MAB.bc, L.bisext)
   L.CD     = line: new (z.C,z.D)
   z.O      = L.CD.mid
   L.AM     = T.MAB.ab
   z.E      = z.M : symmetry (z.A)
}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}

\begin{center}
  \begin{tikzpicture}[scale=.5]
     \tkzGetNodes
     \tkzDrawSegment[add=0 and 1](A,M)
     \tkzDrawSegments[purple](M,C M,D)
     \tkzDrawCircle[purple](O,C)
     \tkzDrawSegments(A,B B,M D,B)
     \tkzDrawPoints(A,B,M,C,D)
     \tkzLabelPoints[below right](A,B,C,D)
     \tkzLabelPoints[above](M)
     \tkzFillAngles[opacity=.4,cyan!20](A,M,B)
     \tkzFillAngles[opacity=.4,purple!20](B,M,E)
     \tkzMarkRightAngle[opacity=.4,fill=gray!20](C,M,D)
     \tkzMarkAngles[mark=|](A,M,C C,M,B)
     \tkzMarkAngles[mark=||](B,M,D D,M,E)
  \end{tikzpicture} 
\end{center}
\end{minipage}

\begin{Verbatim}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawSegment[add=0 and 1](A,M)
   \tkzDrawSegments[purple](M,C M,D)
   \tkzDrawCircle[purple](O,C)
   \tkzDrawSegments(A,B B,M D,B)
   \tkzDrawPoints(A,B,M,C,D)
   \tkzLabelPoints[below right](A,B,C,D)
   \tkzLabelPoints[above](M)
   \tkzFillAngles[opacity=.4,cyan!20](A,M,B)
   \tkzFillAngles[opacity=.4,purple!20](B,M,E)
   \tkzMarkRightAngle[opacity=.4,fill=gray!20](C,M,D)
   \tkzMarkAngles[mark=|](A,M,C C,M,B)
   \tkzMarkAngles[mark=||](B,M,D D,M,E)
\end{tikzpicture} 
\end{Verbatim}

Remark : The circle can be obtained with:

|C.AB = T.MAB.bc : apollonius (length(z.M,z.A)/length(z.M,z.B))|


%subsection apollonius_circle (end)

\subsection{Apollonius and circle circumscribed } % (fold)
\label{sub:apollonius_and_circle_circumscribed}

\begin{Verbatim}
\directlua{%
init_elements ()
 z.A   = point: new (0 , 0)
 z.B   = point: new (6 , 0)
 z.M   = point: new (5 , 4)
 T.AMB = triangle: new (z.A,z.M,z.B)
 L.AB  = T.AMB.ca
 z.I   = T.AMB.incenter
 L.MI  = line: new (z.M,z.I)
 z.C   = intersection (L.AB , L.MI)
 L.MJ  = L.MI: ortho_from (z.M)
 z.D   = intersection (L.AB , L.MJ)
 L.CD  = line: new (z.C,z.D)
 z.O   = L.CD.mid
 z.G   = T.AMB.circumcenter
 C.GA  = circle: new (z.G,z.A)
 C.OC  = circle: new (z.O,z.C)
 _,z.N = intersection (C.GA , C.OC)
}
\begin{tikzpicture}[scale =.75]
   \tkzGetNodes
   \tkzDrawPolygon(A,B,M)
   \tkzDrawCircles[purple](O,C G,A)
   \tkzDrawSegments[purple](M,D)
   \tkzDrawSegments(D,B O,G M,C)
   \tkzDrawSegments[red,dashed](M,N M,O M,G)
   \tkzDrawPoints(A,B,M,C,D,N,O,G)
   \tkzLabelPoints[below right](A,B,C,D,N,O,G)
   \tkzLabelPoints[above](M)
   \tkzMarkRightAngle[opacity=.4,fill=gray!20](C,M,D)
\end{tikzpicture}
\end{Verbatim}


\directlua{%
init_elements ()
   z.A   = point: new (0 , 0)
   z.B   = point: new (6 , 0)
   z.M   = point: new (5 , 4)
   T.AMB = triangle: new (z.A,z.M,z.B)
   L.AB  = T.AMB.ca
   z.I   = T.AMB.incenter
   L.MI  = line: new (z.M,z.I)
   z.C   = intersection (L.AB , L.MI)
   L.MJ  = L.MI: ortho_from (z.M)
   z.D   = intersection (L.AB , L.MJ)
   L.CD  = line: new (z.C,z.D)
   z.O   = L.CD.mid
   z.G   = T.AMB.circumcenter
   C.GA  = circle: new (z.G,z.A)
   C.OC  = circle: new (z.O,z.C)
   _,z.N = intersection (C.GA , C.OC)
}


\begin{center}
  \begin{tikzpicture}[ scale =.75]
  \tkzGetNodes
  \tkzDrawPolygon(A,B,M)
  \tkzDrawCircles[purple](O,C G,A)
  \tkzDrawSegments[purple](M,D)
  \tkzDrawSegments(D,B O,G M,C)
  \tkzDrawSegments[red,dashed](M,N M,O M,G)
  \tkzDrawPoints(A,B,M,C,D,N,O,G)
  \tkzLabelPoints[below right](A,B,C,D,N,O,G)
  \tkzLabelPoints[above](M)
  \tkzMarkRightAngle[opacity=.4,fill=gray!20](C,M,D)
  \end{tikzpicture}
\end{center}


% subsection apollonius_and_circle_circumscribed (end)

\subsection{Apollonius circles in a triangle} % (fold)
\label{sub:apollonius_circles}


\begin{Verbatim}
\directlua{%
init_elements ()
   z.A   = point: new (0 , 0)
   z.B   = point: new (6 , 0)   
   z.C   = point: new (4.5 , 1)
   T.ABC = triangle: new (z.A,z.B,z.C)
   z.I   = T.ABC.incenter
   z.O   = T.ABC.circumcenter    
   L.CI  = line: new (z.C,z.I)
   z.Cp  = intersection (T.ABC.ab , L.CI)
   z.x   = L.CI.north_pa
   L.Cx  = line: new (z.C,z.x)
   z.R   = intersection (L.Cx,T.ABC.ab)
   L.CpR = line: new (z.Cp,z.R)
   z.O1  = L.CpR.mid   
   L.AI  = line: new (z.A,z.I)
   z.Ap  = intersection (T.ABC.bc , L.AI)
   z.y   = L.AI.north_pa
   L.Ay  = line: new (z.A,z.y)
   z.S   = intersection (L.Ay,T.ABC.bc)
   L.ApS = line: new (z.Ap,z.S)
   z.O2  = L.ApS.mid 
   L.BI  = line: new (z.B,z.I)
   z.Bp  = intersection (T.ABC.ca , L.BI)
   z.z   = L.BI.north_pa
   L.Bz  = line: new (z.B,z.z)
   z.T   = intersection (L.Bz,T.ABC.ca)
   L.Bpt = line: new (z.Bp,z.T)
   z.O3  = L.Bpt.mid
}
\end{Verbatim}
\begin{Verbatim}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawCircles[blue!50!black](O1,C' O2,A' O3,B')
   \tkzDrawSegments[new](B,S C,T A,R)
   \tkzDrawPolygon(A,B,C)
   \tkzDrawPoints(A,B,C,A',B',C',O,I,R,S,T,O1,O2,O3)
   \tkzLabelPoints(A,B,C,A',B',C',O,I)
   \tkzLabelPoints(O1,O2,O3)
   \tkzDrawCircle[purple](O,A)
   \tkzDrawLine(O1,O2)
\end{tikzpicture}
\end{Verbatim}

\directlua{%
init_elements ()
z.A   = point: new (0 , 0)
z.B   = point: new (6 , 0)   
z.C   = point: new (4.5 , 1)
T.ABC = triangle: new (z.A,z.B,z.C)
z.I   = T.ABC.incenter
z.O   = T.ABC.circumcenter    
L.CI  = line: new (z.C,z.I)
z.Cp  = intersection (T.ABC.ab , L.CI)
z.x   = L.CI.north_pa
L.Cx  = line: new (z.C,z.x)
z.R   = intersection (L.Cx,T.ABC.ab)
L.CpR = line: new (z.Cp,z.R)
z.O1  = L.CpR.mid   
L.AI  = line: new (z.A,z.I)
z.Ap  = intersection (T.ABC.bc , L.AI)
z.y   = L.AI.north_pa
L.Ay  = line: new (z.A,z.y)
z.S   = intersection (L.Ay,T.ABC.bc)
L.ApS = line: new (z.Ap,z.S)
z.O2  = L.ApS.mid 
L.BI  = line: new (z.B,z.I)
z.Bp  = intersection (T.ABC.ca , L.BI)
z.z   = L.BI.north_pa
L.Bz  = line: new (z.B,z.z)
z.T   = intersection (L.Bz,T.ABC.ca)
L.Bpt = line: new (z.Bp,z.T)
z.O3  = L.Bpt.mid
}


\begin{center}
  \begin{tikzpicture}
  \tkzGetNodes
  \tkzDrawCircles[blue!50!black](O1,C' O2,A' O3,B')
  \tkzDrawSegments[new](B,S C,T A,R)
  \tkzDrawPolygon(A,B,C)
  \tkzDrawPoints(A,B,C,A',B',C',O,I,R,S,T,O1,O2,O3)
  \tkzLabelPoints(A,B,C,A',B',C',O,I)
  \tkzLabelPoints(O1,O2,O3)
  \tkzDrawCircle[purple](O,A)
  \tkzDrawLine(O1,O2)
  \end{tikzpicture}
\end{center}



Same result using the function |T.ABC.ab : apollonius (k) |

\begin{Verbatim}
\directlua{%
 init_elements ()  
z.A         = point: new (0 , 0)
z.B         = point: new (6 , 0)
z.C         = point: new (4.5 , 1)
T.ABC       = triangle : new (z.A,z.B,z.C)
z.O         = T.ABC.circumcenter
C.AB        = T.ABC.ab : apollonius (length(z.C,z.A)/length(z.C,z.B))
z.w1,z.t1   = get_points ( C.AB )
C.AC        = T.ABC.ca : apollonius (length(z.B,z.C)/length(z.B,z.A))
z.w2,z.t2   = get_points ( C.AC )
C.BC        = T.ABC.bc : apollonius (length(z.A,z.B)/length(z.A,z.C))
z.w3,z.t3   = get_points ( C.BC )
}
\end{Verbatim}

% subsection apollonius_circles (end)

\subsection{Archimedes} % (fold)
\label{sub:archimedes}

\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\begin{Verbatim}
\directlua{%
init_elements ()
z.O_1    = point:   new  (0, 0)
z.O_2    = point:   new  (0, 1)
z.A      = point:   new  (0, 3)
z.F      = point:   polar (3, math.pi/6)
L        = line:    new   (z.F,z.O_1)
C        = circle:  new  (z.O_1,z.A)
z.E      = intersection (L,C)
T        = triangle: new (z.F,z.E,z.O_2)
z.x      = T: parallelogram ()
L        = line: new    (z.x,z.O_2)
C        = circle: new  (z.O_2,z.A)
z.C,z.D  = intersection (L ,C)
}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawCircles(O_1,A O_2,A)
   \tkzDrawSegments[new](O_1,A E,F C,D)
   \tkzDrawSegments[purple](A,E A,F)
   \tkzDrawPoints(A,O_1,O_2,E,F,C,D)
   \tkzLabelPoints(A,O_1,O_2,E,F,C,D)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\directlua{%
 init_elements ()
 z.O_1  = point:   new  (0, 0)
 z.O_2  = point:   new  (0, 1)
 z.A    = point:   new  (0, 3)
 z.F    = point:   polar (3, math.pi/6)
 L  = line:    new   (z.F,z.O_1)
 C  = circle:  new  (z.O_1,z.A)
 z.E    = intersection (L,C)
 T  = triangle: new (z.F,z.E,z.O_2)
 z.x    = T: parallelogram ()
 L     = line: new    (z.x,z.O_2)
 C     = circle: new  (z.O_2,z.A)
 z.C,z.D   = intersection (L ,C)
}

\begin{center}
  \begin{tikzpicture}
  \tkzGetNodes
  \tkzDrawCircles(O_1,A O_2,A)
  \tkzDrawSegments[new](O_1,A E,F C,D)
  \tkzDrawSegments[purple](A,E A,F)
  \tkzDrawPoints(A,O_1,O_2,E,F,C,D)
  \tkzLabelPoints(A,O_1,O_2,E,F,C,D)
  \end{tikzpicture}
\end{center}

\end{minipage}
% subsection archimedes (end)

\subsection{Bankoff circle} % (fold)
\label{sub:bankoff_circle}
\begin{Verbatim}
\directlua{%
   init_elements ()
   z.A      = point: new (0 , 0)
   z.B      = point: new (10 , 0)
   L.AB     = line : new (z.A,z.B)
   z.C      = L.AB: gold_ratio ()
   L.AC     = line : new (z.A,z.C)
   L.CB     = line : new (z.C,z.B)
   z.O_0    = L.AB.mid
   z.O_1    = L.AC.mid
   z.O_2    = L.CB.mid
   C.O0B    = circle : new (z.O_0,z.B)
   C.O1C    = circle : new (z.O_1,z.C)
   C.O2C    = circle : new (z.O_2,z.B)
   z.Pp     = C.O0B : midarc (z.B,z.A)
   z.P      = C.O1C : midarc (z.C,z.A)
   z.Q      = C.O2C : midarc (z.B,z.C)
   L.O1O2   = line : new (z.O_1,z.O_2)
   L.O0O1   = line : new (z.O_0,z.O_1)
   L.O0O2   = line : new (z.O_0,z.O_2)
   z.M_0    = L.O1O2 : harmonic_ext (z.C)
   z.M_1    = L.O0O1 : harmonic_int (z.A)
   z.M_2    = L.O0O2 : harmonic_int (z.B)
   L.BP     = line : new (z.B,z.P)
   L.AQ     = line : new (z.A,z.Q)
   z.S      = intersection (L.BP,L.AQ)
   L.PpO0   = line : new (z.Pp,z.O_0)
   L.PC     = line : new (z.P,z.C)
   z.Ap     = intersection (L.PpO0,L.PC)
   L.CS     = line : new (z.C,z.S)
   C.M1A    = circle : new (z.M_1,z.A)
   C.M2B    = circle : new (z.M_2,z.B)
   z.P_0    = intersection (L.CS,C.O0B)
   z.P_1    = intersection (C.M2B,C.O1C)
   z.P_2    = intersection (C.M1A,C.O2C)
   T.P0P1P2 = triangle : new (z.P_0,z.P_1,z.P_2)
   z.O_4    = T.P0P1P2.circumcenter
   T.CP1P2  = triangle : new (z.C,z.P_1,z.P_2)
   z.O_5    = T.CP1P2.circumcenter
}
\end{Verbatim}

\begin{Verbatim}
\begin{tikzpicture}
\tkzGetNodes
\tkzDrawSemiCircles[teal](O_0,B)
\tkzDrawSemiCircles[teal,fill=teal!20,opacity=.5](O_1,C O_2,B)
\tkzDrawCircle[fill=green!10](O_4,P_0)
\tkzDrawCircle[purple,fill=purple!10,opacity=.5](O_5,C)
\tkzDrawSegments(A,B O_0,P' B,P A,Q)
\tkzDrawSegments(P,B Q,O_2 P,O_1)
\tkzDrawSegments[purple](O_5,P_2 O_5,P_1 O_5,C)
\tkzDrawPoints(A,B,C,P_0,P_2,P_1,O_0,O_1,O_2,O_4,O_5,Q,P,P',S)
\tkzLabelPoints[below](A,B,C,O_0,O_1,O_2,P')
\tkzLabelPoints[above](Q,P)
\tkzLabelPoints[above right](P_0,P_2,P_1,O_5,O_4,S)
\begin{scope}[font=\scriptsize]
  \tkzLabelCircle[above](O_1,C)(120){$(\beta)$}
  \tkzLabelCircle[above](O_2,B)(70){$(\gamma)$}
  \tkzLabelCircle[above](O_0,B)(110){$(\alpha)$}
  \tkzLabelCircle[left](O_4,P_2)(60){$(\delta)$}
  \tkzLabelCircle[left](O_5,C)(140){$(\epsilon)$}
\end{scope}
\end{tikzpicture}
\end{Verbatim}


\directlua{%
init_elements ()
   z.A  = point: new (0 , 0)
   z.B  = point: new (10 , 0)
   L.AB = line : new (z.A,z.B)
   z.C  = L.AB: gold_ratio ()
   L.AC = line : new (z.A,z.C)
   L.CB = line : new (z.C,z.B)
   z.O_0    = L.AB.mid
   z.O_1    = L.AC.mid
   z.O_2    = L.CB.mid
   C.O0B    = circle : new (z.O_0,z.B)
   C.O1C    = circle : new (z.O_1,z.C)
   C.O2C    = circle : new (z.O_2,z.B)
   z.Pp = C.O0B : midarc (z.B,z.A)
   z.P  = C.O1C : midarc (z.C,z.A)
   z.Q  = C.O2C : midarc (z.B,z.C)
   L.O1O2   = line : new (z.O_1,z.O_2)
   L.O0O1   = line : new (z.O_0,z.O_1)
   L.O0O2   = line : new (z.O_0,z.O_2)
   z.M_0    = L.O1O2 : harmonic_ext (z.C)
   z.M_1    = L.O0O1 : harmonic_int (z.A)
   z.M_2    = L.O0O2 : harmonic_int (z.B)
   L.BP = line : new (z.B,z.P)
   L.AQ = line : new (z.A,z.Q)
   z.S  = intersection (L.BP,L.AQ)
   L.PpO0   = line : new (z.Pp,z.O_0)
   L.PC = line : new (z.P,z.C)
   z.Ap = intersection (L.PpO0,L.PC)
   L.CS = line : new (z.C,z.S)
   C.M1A    = circle : new (z.M_1,z.A)
   C.M2B    = circle : new (z.M_2,z.B)
   z.P_0    = intersection (L.CS,C.O0B)
   z.P_1    = intersection (C.M2B,C.O1C)
   z.P_2    = intersection (C.M1A,C.O2C)
   T.P0P1P2 = triangle : new (z.P_0,z.P_1,z.P_2)
   z.O_4    = T.P0P1P2.circumcenter
   T.CP1P2  = triangle : new (z.C,z.P_1,z.P_2)
   z.O_5    = T.CP1P2.circumcenter
}

\begin{center}
  \begin{tikzpicture}[scale = 1.25]
  \tkzGetNodes
  \tkzDrawSemiCircles[teal](O_0,B)
  \tkzDrawSemiCircles[teal,fill=teal!20,opacity=.5](O_1,C O_2,B)
  \tkzDrawCircle[fill=green!10](O_4,P_0)
  \tkzDrawCircle[purple,fill=purple!10,opacity=.5](O_5,C)
  \tkzDrawSegments(A,B O_0,P' B,P A,Q)
  \tkzDrawSegments(P,B Q,O_2 P,O_1)
  \tkzDrawSegments[purple](O_5,P_2 O_5,P_1 O_5,C)
  \tkzDrawPoints(A,B,C,P_0,P_2,P_1,O_0,O_1,O_2,O_4,O_5,Q,P,P',S)
  \tkzLabelPoints[below](A,B,C,O_0,O_1,O_2,P')
  \tkzLabelPoints[above](Q,P)
  \tkzLabelPoints[above right](P_0,P_2,P_1,O_5,O_4,S)
  \begin{scope}[font=\scriptsize]
    \tkzLabelCircle[above](O_1,C)(120){$(\beta)$}
    \tkzLabelCircle[above](O_2,B)(70){$(\gamma)$}
    \tkzLabelCircle[above](O_0,B)(110){$(\alpha)$}
    \tkzLabelCircle[left](O_4,P_2)(60){$(\delta)$}
    \tkzLabelCircle[left](O_5,C)(140){$(\epsilon)$}
  \end{scope}
  \end{tikzpicture}
\end{center}

% subsection bankoff_circle (end)

\subsection{Symmedian property} % (fold)
\label{sub:example_symmedian_property}

$L$ is the symmedian point or lemoine point. $\dfrac{CL}{CLc} = \dfrac{a^2+b^2}{a^2+b^2+c^2}$

\vspace{6pt}
\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
 init_elements ()
 z.A     = point :   new (1,2)
 z.B     = point :   new (5,1)
 z.C     = point :   new (3,5)
 T.ABC   = triangle : new (z.A,z.B,z.C)
 T.SY    = T.ABC : symmedian ()
 z.La,
 z.Lb,
 z.Lc    = get_points (T.SY) 
 k       = (T.ABC.a*T.ABC.a +    
            T.ABC.b*T.ABC.b)/(T.ABC.a*T.ABC.a +     
            T.ABC.b*T.ABC.b+T.ABC.c*T.ABC.c)
 L.SY    = line : new (z.C,z.Lc)
 z.L     = L.SY : point (k)
}
\begin{tikzpicture}
 \tkzGetNodes
 \tkzDrawPolygons(A,B,C)
 \tkzDrawPoints(A,B,C,L,Lc)
 \tkzDrawPoints[red](L)
 \tkzDrawSegments[cyan](C,Lc)
 \tkzLabelPoints(A,B,Lc)
 \tkzLabelPoints[above](C)
 \tkzLabelPoints[left](L)
 \tkzLabelSegment(B,C){$a$}
 \tkzLabelSegment(A,C){$b$}
 \tkzLabelSegment(A,B){$ca$}
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{%
   init_elements ()
   z.A            = point :   new (1,2)
   z.B            = point :   new (5,1)
   z.C            = point :   new (3,5)
   T.ABC          = triangle : new (z.A,z.B,z.C)
   T.SY           = T.ABC : symmedian ()
   z.La,z.Lb,z.Lc = get_points (T.SY) 
   k              = (T.ABC.a*T.ABC.a +    
                    T.ABC.b*T.ABC.b)/(T.ABC.a*T.ABC.a +     
                    T.ABC.b*T.ABC.b+T.ABC.c*T.ABC.c)
   L.SY            = line : new (z.C,z.Lc)
   z.L             = L.SY : point (k)
}
\begin{center}
  \begin{tikzpicture}[scale = 1.5]
  \tkzGetNodes
  \tkzDrawPolygons(A,B,C)
  \tkzDrawPoints(A,B,C,L,Lc)
  \tkzDrawPoints[red](L)
  \tkzDrawSegments[cyan](C,Lc)
  \tkzLabelPoints(A,B,Lc)
  \tkzLabelPoints[above](C)
  \tkzLabelPoints[left](L)
  \tkzLabelSegment(B,C){$a$}
  \tkzLabelSegment(A,C){$b$}
  \tkzLabelSegment(A,B){$ca$}
  \end{tikzpicture}
  \end{center}
\end{minipage}


% subsection example_symmedian_property (end)

\subsection{Example: Cevian with orthocenter} % (fold)
\label{sub:example_cevian_with_orthocenter}
\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
  init_elements ()
  z.a   = point:  new (1,2)
  z.b   = point:  new (5,1)
  z.c   = point:  new (3,5)
  T     = triangle: new (z.a,z.b,z.c)
  z.i   = T.orthocenter
  T.cevian = T : cevian (z.i)
  z.ta,
  z.tb,
  z.tc = get_points (T.cevian)
  C.cev = T : cevian_circle (z.i)
  z.w   = C.cev.center
}
\begin{tikzpicture}[scale =  1.5]
  \tkzGetNodes
  \tkzDrawPolygons(a,b,c ta,tb,tc)
  \tkzDrawSegments(a,ta b,tb c,tc)
  \tkzDrawPoints(a,b,c,i,ta,tb,tc)
  \tkzLabelPoints(a,b,c,i)
  \tkzDrawCircles(w,ta)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{%
init_elements ()
z.a = point:  new (1,2)
z.b = point:  new (5,1)
z.c = point:  new (3,5)
T = triangle: new (z.a,z.b,z.c)
z.i = T.orthocenter
T.cevian = T : cevian (z.i)
z.ta,z.tb,z.tc = get_points (T.cevian)
C.cev = T : cevian_circle (z.i)
z.w = C.cev.center
}
\begin{center}
  \begin{tikzpicture}[scale =  1.5]
  \tkzGetNodes
  \tkzDrawPolygons(a,b,c ta,tb,tc)
  \tkzDrawSegments(a,ta b,tb c,tc)
  \tkzDrawPoints(a,b,c,i,ta,tb,tc)
  \tkzLabelPoints(a,b,c,i)
  \tkzDrawCircles(w,ta)
  \end{tikzpicture}
\end{center}
\end{minipage}

% subsection example_cevian_with_orthocenter (end)

\subsection{Excircles} % (fold)
\label{sub:excircles}

\begin{Verbatim}
\directlua{%
 init_elements ()
 z.A    = point: new (0,0)
 z.B    = point: new (6,0)
 z.C    = point: new (.8,4)
 T      = triangle: new ( z.A, z.B, z.C)
 z.K    = T.centroid
 z.J_a,
 z.J_b,
 z.J_c  = get_points (T: excentral())
 z.T_a,
 z.T_b,
 z.T_c  = get_points (T: extouch())
 la     = line: new ( z.A, z.T_a)
 lb     = line: new ( z.B, z.T_b)
 z.G    = intersection (la,lb)
}
\begin{tikzpicture}[scale  =  0.7]
   \tkzGetNodes
   \tkzDrawPoints[new](J_a,J_b,J_c)
   \tkzClipBB
   \tkzDrawCircles[gray](J_a,T_a J_b,T_b J_c,T_c)
   \tkzDrawLines[add=1 and 1](A,B B,C C,A)
   \tkzDrawSegments[new](A,T_a B,T_b C,T_c)
   \tkzDrawSegments[new](J_a,T_a J_b,T_b J_c,T_c)
   \tkzDrawPolygon(A,B,C)
   \tkzDrawPolygon[new](T_a,T_b,T_c)
   \tkzDrawPoints(A,B,C,K)
   \tkzDrawPoints[new](T_a,T_b,T_c)
   \tkzLabelPoints[below left](A)
   \tkzLabelPoints[below](B)
   \tkzLabelPoints[above](C)
   \tkzLabelPoints[new,below left](T_b)
   \tkzLabelPoints[new,below right](T_c)
   \tkzLabelPoints[new,right=6pt](T_a)
   \tkzMarkRightAngles[fill=gray!15](J_a,T_a,B J_b,T_b,C J_c,T_c,A)
\end{tikzpicture}
\end{Verbatim}

\directlua{%
init_elements ()
   z.A    = point: new (0,0)
   z.B    = point: new (6,0)
   z.C    = point: new (.8,4)
   T      = triangle: new ( z.A, z.B, z.C)
   z.K    = T.centroid
   z.J_a,z.J_b,z.J_c  = get_points (T: excentral())
   z.T_a,z.T_b,z.T_c  = get_points (T: extouch())
   la     = line: new ( z.A, z.T_a)
   lb     = line: new ( z.B, z.T_b)
   z.G    = intersection (la,lb)
}


\begin{center}
  \begin{tikzpicture}[scale=0.7]
  \tkzGetNodes
  \tkzDrawPoints[new](J_a,J_b,J_c)
  \tkzClipBB
  \tkzDrawCircles[gray](J_a,T_a J_b,T_b J_c,T_c)
  \tkzDrawLines[add=1 and 1](A,B B,C C,A)
  \tkzDrawSegments[new](A,T_a B,T_b C,T_c)
  \tkzDrawSegments[new](J_a,T_a J_b,T_b J_c,T_c)
  \tkzDrawPolygon(A,B,C)
  \tkzDrawPolygon[new](T_a,T_b,T_c)
  \tkzDrawPoints(A,B,C,K)
  \tkzDrawPoints[new](T_a,T_b,T_c)
  \tkzLabelPoints[below left](A)
  \tkzLabelPoints[below](B)
  \tkzLabelPoints[above](C)
  \tkzLabelPoints[new,below left](T_b)
  \tkzLabelPoints[new,below right](T_c)
  \tkzLabelPoints[new,right=6pt](T_a)
  \tkzMarkRightAngles[fill=gray!15](J_a,T_a,B J_b,T_b,C J_c,T_c,A)
  \end{tikzpicture}
\end{center}


% subsection excircles (end)


\subsection{Divine ratio} % (fold)
\label{sub:divine_ratio}

\begin{Verbatim}
\directlua{%
init_elements ()
z.A         = point: new (0 , 0)
z.B         = point: new (8 , 0)
L.AB        = line: new (z.A,z.B)
z.C         = L.AB: gold_ratio ()
L.AC        = line: new (z.A,z.C)
z.O_1       = L.AC.mid
_,_,z.G,z.H = get_points(L.AB: square ())
_,_,z.E,z.F = get_points(L.AC: square ())
L.CB        = line: new (z.C,z.B)
z.O_2       = L.CB.mid
z.O_0       = L.AB.mid
L.BE        = line: new (z.B,z.E)
L.GH        = line: new (z.G,z.H)
z.K         = intersection (L.BE,L.GH)
C0          = circle: new (z.O_0,z.B)
z.R,_       = intersection (L.BE,C0)
C2          = circle: new (z.O_2,z.B)
z.S,_       = intersection (L.BE,C2)
L.AR        = line:   new (z.A,z.R)
C1          = circle: new (z.O_1,z.C)
_,z.T       = intersection (L.AR,C1)
L.BG        = line: new (z.B,z.G)
z.L         = intersection (L.AR,L.BG)
}
\begin{tikzpicture}
\tkzGetNodes
\tkzDrawPolygons(A,C,E,F A,B,G,H)
\tkzDrawCircles(O_1,C O_2,B O_0,B)
\tkzDrawSegments(H,C B,K A,L)
\tkzDrawPoints(A,B,C,K,E,F,G,H,O_0,O_1,O_2,R,S,T,L)
\tkzLabelPoints(A,B,C,K,E,F,G,H,O_0,O_1,O_2,R,S,T,L)
\end{tikzpicture}
\end{Verbatim}

\directlua{%
init_elements ()
 z.A     = point: new (0 , 0)
 z.B     = point: new (8 , 0)
 L.AB    = line: new (z.A,z.B)
 z.C     = L.AB: gold_ratio ()
 L.AC    = line: new (z.A,z.C)
 z.O_1   = L.AC.mid
 _,_,z.G,
 z.H     = get_points(L.AB: square ())
 _,_,z.E,
 z.F     = get_points(L.AC: square ())
 L.CB    = line: new (z.C,z.B)
 z.O_2   = L.CB.mid
 z.O_0   = L.AB.mid
 L.BE    = line: new (z.B,z.E)
 L.GH    = line: new (z.G,z.H)
 z.K     = intersection (L.BE,L.GH)
 C0      = circle: new (z.O_0,z.B)
 z.R,_   = intersection (L.BE,C0)
 C2      = circle: new (z.O_2,z.B)
 z.S,_   = intersection (L.BE,C2)
 L.AR    = line:   new (z.A,z.R)
 C1      = circle: new (z.O_1,z.C)
 _,z.T   = intersection (L.AR,C1)
 L.BG    = line: new (z.B,z.G)
 z.L     = intersection (L.AR,L.BG)
}


\begin{center}
\begin{tikzpicture}
  \tkzGetNodes
  \tkzDrawPolygons(A,C,E,F A,B,G,H)
  \tkzDrawCircles(O_1,C O_2,B O_0,B)
  \tkzDrawSegments(H,C B,K A,L)
  \tkzDrawPoints(A,B,C,K,E,F,G,H,O_0,O_1,O_2,R,S,T,L)
  \tkzLabelPoints(A,B,C,K,E,F,G,H,O_0,O_1,O_2,R,S,T,L)
\end{tikzpicture}
\end{center}


% subsection divine_ratio (end)

\subsection{Director circle} % (fold)
\label{sub:director_circle}
% modif C: point (0.25) instead of 2

\begin{Verbatim}
\directlua{%
 z.O            = point: new (0 , 0)
 z.F1           = point: new (4 , 0)
 z.F2           = point: new (-4 , 0)
 z.H            = point: new (4*math.sqrt(2) , 0)
 local a        = length(z.O,z.H)
 E              = conic : new (EL_bifocal(z.F2,z.F1,a))
 curve          = E : points(0,1,50)
 z.A            = E.covertex
 T.HOA          = triangle: new (z.H,z.O,z.A)
 z.P            = T.HOA: parallelogram ()
 C.OP           = circle: new (z.O,z.P)
 z.L            = C.OP: point (0.25)
 T.LJ ,T.LK     = E: tangent_from (z.L)
 z.J            = T.LJ.pb
 z.K            = T.LK.pb
}
 \begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPoints(F1,F2,O)
   \tkzDrawCircles[teal](O,P)
   \tkzDrawPolygon(H,O,A,P)
   \tkzDrawCoordinates[smooth,cyan](curve)
   \tkzDrawSegments[orange](O,P O,L L,J L,K)
   \tkzDrawPoints(F1,F2,O,H,A,P,L,J,K)
   \tkzLabelPoints(F1,F2,O,H,A,P,L,J,K)
\end{tikzpicture}
\end{Verbatim}

\directlua{%
 z.O            = point: new (0 , 0)
 z.F1           = point: new (4 , 0)
 z.F2           = point: new (-4 , 0)
 z.H            = point: new (4*math.sqrt(2) , 0)
 local a        = length(z.O,z.H)
 E              = conic : new (EL_bifocal(z.F2,z.F1,a))
 curve          = E : points(0,1,50)
 z.A            = E.covertex
 T.HOA          = triangle: new (z.H,z.O,z.A)
 z.P            = T.HOA: parallelogram ()
 C.OP           = circle: new (z.O,z.P)
 z.L            = C.OP: point (0.25)
 T.LJ ,T.LK     = E: tangent_from (z.L)
 z.J            = T.LJ.pb
 z.K            = T.LK.pb
}
\begin{center}
  \begin{tikzpicture}[scale = .75]
   \tkzGetNodes
   \tkzDrawPoints(F1,F2,O)
   \tkzDrawCircles[teal](O,P)
   \tkzDrawPolygon(H,O,A,P)
   \tkzDrawCoordinates[smooth,cyan](curve)
   \tkzDrawSegments[orange](O,P O,L L,J L,K)
   \tkzDrawPoints(F1,F2,O,H,A,P,L,J,K)
   \tkzLabelPoints(F1,F2,O,H,A,P,L,J,K)
\end{tikzpicture}
\end{center}

% subsection director_circle (end)

\subsection{Gold division} % (fold)
\label{sub:gold_division}

\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
z.A         = point:  new (0,0)
z.B         = point:  new (2.5,0)
L.AB        = line:   new (z.A,z.B)
C.AB        = circle: new (z.A,z.B)
C.BA        = circle: new (z.B,z.A)
z.J         = L.AB: midpoint ()
L.JB        = line:new (z.J,z.B)
z.F,z.E     = intersection (C.AB , C.BA)
z.I,_       = intersection (L.AB , C.BA)
z.K         = L.JB : midpoint ()
L.mediator  = L.JB: mediator ()
z.G         = intersection (L.mediator,C.BA)
L.EG        = line:new (z.E,z.G)
z.C         = intersection  (L.EG,L.AB)
z.O         = C.AB: antipode (z.B)
}
\begin{tikzpicture}
\tkzGetNodes
\tkzDrawArc[delta=5](O,B)(G)
\tkzDrawCircles(A,B B,A)
\tkzDrawSegments(A,E B,E O,I)
\tkzDrawSegments[purple](J,E A,G G,I K,G E,G)
\tkzMarkSegments[mark=s||](A,E B,E O,A)
\tkzDrawPoints(A,B,C,E,I,J,G,O,K)
\tkzLabelPoints(A,B,C,E,I,J,G,O,K)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
  \directlua{%
  init_elements ()
  z.A     = point:  new (0,0)
  z.B     = point:  new (2.5,0)
  L.AB    = line:   new (z.A,z.B)
  C.AB    = circle: new (z.A,z.B)
  C.BA    = circle: new (z.B,z.A)
  z.J     = L.AB: midpoint ()
  L.JB    = line:new (z.J,z.B)
  z.F,z.E = intersection (C.AB , C.BA)
  z.I,_   = intersection (L.AB , C.BA)
  z.K     = L.JB : midpoint ()
  L.mediator  = L.JB: mediator ()
  z.G   = intersection (L.mediator,C.BA)
  L.EG    = line:new (z.E,z.G)
  z.C     = intersection  (L.EG,L.AB)
  z.O     = C.AB: antipode (z.B)
  }

  \begin{center}
    \begin{tikzpicture}[scale = .75]
       \tkzGetNodes
       \tkzDrawArc[delta=5](O,B)(G)
       \tkzDrawCircles(A,B B,A)
       \tkzDrawSegments(A,E B,E O,I)
       \tkzDrawSegments[purple](J,E A,G G,I K,G E,G)
       \tkzMarkSegments[mark=s||](A,E B,E O,A)
       \tkzDrawPoints(A,B,C,E,I,J,G,O,K)
       \tkzLabelPoints(A,B,C,E,I,J,G,O,K)
    \end{tikzpicture}
  \end{center}
\end{minipage}

% subsection gold_division (end)

\subsection{Ellipse} % (fold)
\label{sub:ellipse}
\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
   z.C       = point: new (3 , 2)
   z.A       = point: new (5 , 1)
   L.CA      = line : new (z.C,z.A)
   z.b       = L.CA.north_pa
   L         = line : new (z.C,z.b)
   z.B       = L : point (0.5)
   E         = conic : new (EL_points (z.C,z.A,z.B))
   curve_E   = E : points(0,1,50)
   z.F         = E.Fa
}

\begin{tikzpicture}
\tkzGetNodes
\tkzDrawCircles[teal](C,A)
\tkzDrawCoordinates[smooth,red,thick](curve_E)
\tkzLabelPoints(C,A)
\tkzLabelPoints[left](F)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{%
init_elements ()
   z.C       = point: new (3 , 2)
   z.A       = point: new (5 , 1)
   L.CA      = line : new (z.C,z.A)
   z.b       = L.CA.north_pa
   L         = line : new (z.C,z.b)
   z.B       = L : point (0.5)
   E         = conic : new (EL_points(z.C,z.A,z.B))
   curve_E   = E : points(0,1,50)
   z.F        = E.Fa
}


\begin{center}
\begin{tikzpicture}
\tkzGetNodes
\tkzDrawCircles[teal](C,A)
\tkzDrawCoordinates[smooth,red,thick](curve_E)
\tkzDrawPoints(C,A,F)
\tkzLabelPoints(C,A)
\tkzLabelPoints[left](F)
\end{tikzpicture}
\end{center}


\end{minipage}
 % subsection ellipse (end)

\subsection{Ellipse with radii} % (fold)
\label{sub:ellipse_with_radii}

In this example, $K$ is the projection of the focus $F$ on the directrix.

\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
z.C     = point: new (0 , 4)
local b = math.sqrt(8)
local a = math.sqrt(32)
local c = math.sqrt(a^2 - b^2)
local e = c / a
z.F  = z.C:rotation(math.pi/4,z.C+point(c 0))
z.K  = z.C:rotation(math.pi/4,z.C+point(a^2/c,0))
z.Kp = (z.K-z.C) : orthogonal(1):at (z.K)
L.dir= line : new (z.K,z.Kp)
E    = conic : new (z.F,L.dir,e)
curve= E : points (0,1,50)
}  
\begin{tikzpicture}[scale=.5]
\tkzGetNodes
\tkzDrawPoints(C,F,K)
\tkzLabelPoints(C,F,K)
\tkzDrawCoordinates[smooth](curve)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{%
init_elements ()
z.C      = point: new (0 , 4)
local b  = math.sqrt(8)
local a  = math.sqrt(32)
local c  = math.sqrt(a^2 - b^2)
local e  = c / a
z.F      = z.C : rotation (math.pi / 4,z.C + point( c, 0 ))
z.K      = z.C : rotation (math.pi / 4,z.C + point( a^2 / c, 0 ))
z.Kp     = (z.K-z.C) : orthogonal (1) : at (z.K)
L.dir    = line : new (z.K,z.Kp)
E        = conic : new (z.F,L.dir,e)
curve    = E : points (0,1,50)
}  

\begin{center}
\begin{tikzpicture}[scale=.5]
\tkzGetNodes
\tkzDrawPoints(C,F,K)
\tkzLabelPoints(C,F,K)
\tkzDrawCoordinates[smooth](curve)
\end{tikzpicture}
\end{center}

\end{minipage}
% subsection ellipse_with_radii (end)

\subsection{Ellipse\_with\_foci} % (fold)
\label{sub:ellipse_with_foci}
\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
 local e   = .8
 z.A       = point: new (2 , 3)
 z.B       = point: new (5 , 4)
 z.K       = point: new (6, 7)  
 L.AB      = line: new (z.A,z.B)
 z.C       = L.AB.mid
 local c   = point.abs(z.B-z.C)
 local a   = c/e 
 EL        = conic : new (EL_bifocal (z.A,z.B,a))
 curve     = EL : points(0,1,50)
 z.cV      = EL.covertex 
 z.V       = EL.vertex
 L.ta,L.tb = EL: tangent_from (z.K)
 z.F       = L.ta.pb
 z.G       = L.tb.pb
}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPoints(A,B,C,K,F,G,V,cV)
   \tkzLabelPoints(A,B,C,K,F,G,V,cV)
   \tkzDrawCoordinates[smooth,cyan](curve)
   \tkzDrawLines(K,F K,G)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{%
init_elements ()
 local e         = .8
 z.A       = point: new (2 , 3)
 z.B       = point: new (5 , 4)
 z.K       = point: new (6, 7)  
 L.AB      = line: new (z.A,z.B)
 z.C       = L.AB.mid
 local c   = point.abs(z.B-z.C)
 local a   = c/e 
 EL        = conic : new (EL_bifocal (z.A,z.B,a))
 curve     = EL : points(0,1,50)
 z.cV      = EL.covertex 
 z.V       = EL.vertex
 L.ta,L.tb = EL: tangent_from (z.K)
 z.F       = L.ta.pb
 z.G       = L.tb.pb
}
\begin{center}
  \begin{tikzpicture}
     \tkzGetNodes
     \tkzDrawPoints(A,B,C,K,F,G,V,cV)
     \tkzLabelPoints(A,B,C,K,F,G,V,cV)
     \tkzDrawCoordinates[smooth,cyan](curve)
     \tkzDrawLines(K,F K,G)
  \end{tikzpicture}
\end{center}
\end{minipage}
% subsection ellipse_with_foci (end)

\subsubsection{Kiepert hyperbola} % (fold)
\label{ssub:kiepert_hyperbola}

In triangle geometry, the Kiepert conics are two special conics associated with the reference triangle. One of them is a hyperbola, called the Kiepert hyperbola and the other is a parabola, called the Kiepert parabola

It has been proved that the Kiepert hyperbola is the hyperbola passing through the vertices, the centroid and the orthocenter of the reference triangle
[Wikipedia]


\begin{Verbatim}
  \directlua{
    init_elements ()
    z.A             = point: new(0,0)
    z.B             = point: new(5,0)
    z.C             = point: new(4,4)
    T               = triangle: new (z.A,z.B,z.C)
    z.K             = T : kimberling (115)
    z.circumcenter  = T.circumcenter
    z.G             = T.centroid
    L.brocard       = T : brocard_axis () 
    C.circum        = circle : new (z.circumcenter,z.A)
    z.M,z.N         = intersection(L.brocard,C.circum)
    L.asx           = T : simson_line(z.M)
    L.asy           = T : simson_line(z.N)
    z.ux,z.uy       = get_points(L.asx)
    z.vx,z.vy       = get_points(L.asy)
     HY             = T : kiepert_hyperbola ()
    curve           = HY : points(-3,3,50)
    curveb          = HY : points(-3,3,50,swap)
    z.F_a,z.F_b     = HY.Fa,HY.Fb
  }
  \begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPolygons(A,B,C)
   \tkzDrawCoordinates[smooth](curve)
   \tkzDrawCoordinates[smooth](curveb)
   \tkzDrawLines(A,B A,C B,C F_a,F_b)
   \tkzDrawLines[red,add = 8 and 5](K,vy)
   \tkzDrawLines[red,add = 2 and 1](K,uy)
   \tkzDrawPoints(A,B,C,K,G,F_a,F_b)
   \tkzLabelPoints(A,B,C,G)
   \tkzLabelPoints[right](F_a,F_b,K)
  \end{tikzpicture}
\end{Verbatim}


\directlua{
  init_elements ()
  z.A             = point: new(0,0)
  z.B             = point: new(5,0)
  z.C             = point: new(4,4)
  T               = triangle: new (z.A,z.B,z.C)
  z.K             = T : kimberling (115)
  z.circumcenter  = T.circumcenter
  z.G             = T.centroid
  L.brocard       = T : brocard_axis () 
  C.circum        = circle : new (z.circumcenter,z.A)
  z.M,z.N         = intersection(L.brocard,C.circum)
  L.asx           = T : simson_line(z.M)
  L.asy           = T : simson_line(z.N)
  z.ux,z.uy       = get_points(L.asx)
  z.vx,z.vy       = get_points(L.asy)
   HY             = T : kiepert_hyperbola ()
  curve           = HY : points(-3,3,50)
  curveb          = HY : points(-3,3,50,swap)
  z.F_a,z.F_b     = HY.Fa,HY.Fb
}
\begin{center}
  \begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPolygons(A,B,C)
   \tkzDrawCoordinates[smooth](curve)
   \tkzDrawCoordinates[smooth](curveb)
   \tkzDrawLines(A,B A,C B,C F_a,F_b)
   \tkzDrawLines[red,add = 8 and 5](K,vy)
   \tkzDrawLines[red,add = 2 and 1](K,uy)
   \tkzDrawPoints(A,B,C,K,G,F_a,F_b)
   \tkzLabelPoints(A,B,C,G)
   \tkzLabelPoints[right](F_a,F_b,K)
  \end{tikzpicture}
\end{center}

% subsubsection kiepert_hyperbola (end)

\subsubsection{Kierpert parabola} % (fold)
\label{ssub:kierpert_parabola}

The Euler line of a triangle is the conic section directrix of the Kiepert parabola. In fact, the directrices of all parabolas inscribed in a triangle pass through the orthocenter. The  triangle  formed by the points of contact is called the Steiner triangle.

The Kiepert parabola is tangent to the sides of the triangle (or their extensions), the line at infinity, and the Lemoine axis. The focus of the parabola has is Kimberling center \code{X\_(110}).

\begin{Verbatim}
\directlua{%
  init_elements ()
   z.A      = point : new ( 0 , 0 )
   z.B      = point : new ( 6, 0 )
   z.C      = point : new ( 1.1, 4.5 )
   T        = triangle : new (z.A, z.B, z.C)
   z.H      = T.orthocenter
   z.O      = T.circumcenter
   kiepert = T :kiepert_parabola ()
   curve    = kiepert : points (-5,7,50)
   z.F      = kiepert.Fa
   z.S      = kiepert.vertex
   z.K      = kiepert.K
   z.a      = intersection (kiepert,T.ab)
   z.b      = intersection (kiepert,T.bc)
   z.c      = intersection (kiepert,T.ca)
  }
  \begin{tikzpicture}
   \tkzGetNodes  
   \tkzDrawPolygon[cyan](A,B,C)
   \tkzDrawPolygon[red](a,b,c)
   \tkzDrawLines[purple,add = .5 and .5](O,H K,F)
   \tkzDrawCoordinates[smooth,red](curve)
   \tkzDrawPoints(A,B,C,F,O,H,K,a,b,c)
   \tkzDrawSegments(C,c C,b)
   \tkzLabelPoints(B,O,H,K,a,b)
   \tkzLabelPoints[above](C)
   \tkzLabelPoints[left](A)
   \tkzLabelPoints[right](F,c)
  \end{tikzpicture}
\end{Verbatim}

\directlua{%
  init_elements ()
   z.A      = point : new ( 0 , 0 )
   z.B      = point : new ( 6, 0 )
   z.C      = point : new ( 1.1, 4.5 )
   T        = triangle : new (z.A, z.B, z.C)
   z.H      = T.orthocenter
   z.O      = T.circumcenter
   kiepert  = T :kiepert_parabola ()
   curve    = kiepert : points (-5,7,50)
   z.F      = kiepert.Fa
   z.S      = kiepert.vertex
   z.K      = kiepert.K
   z.a      = intersection (kiepert,T.ab)
   z.b      = intersection (kiepert,T.bc)
   z.c      = intersection (kiepert,T.ca)
  }
  \begin{center}
    \begin{tikzpicture}
     \tkzGetNodes  
     \tkzDrawPolygon[cyan](A,B,C)
     \tkzDrawPolygon[red](a,b,c)
     \tkzDrawLines[purple,add = .5 and .5](O,H K,F)
     \tkzDrawCoordinates[smooth,red](curve)
     \tkzDrawPoints(A,B,C,F,O,H,K,a,b,c)
     \tkzDrawSegments(C,c C,b)
     \tkzLabelPoints(B,O,H,K,a,b)
     \tkzLabelPoints[above](C)
     \tkzLabelPoints[left](A)
     \tkzLabelPoints[right](F,c)
    \end{tikzpicture}
  \end{center}


% subsubsection kierpert_parabola (end)
\subsection{Euler relation} % (fold)
\label{sub:euler_relation}

\begin{Verbatim}
\directlua{%
init_elements ()
 z.A        = point: new (0 , 0)
 z.B        = point: new (5 , 0)
 z.C        = point: new (-.4 , 4)
 T.ABC      = triangle: new (z.A,z.B,z.C)
 z.J,z.K    = get_points(T.ABC: ex_circle (2))
 z.X,z.Y,z.K= T.ABC : projection (z.J)
 z.I,z.H    = get_points(T.ABC : in_circle())
 z.O        = T.ABC.circumcenter
 C.OA       = circle : new (z.O,z.A)
 T.IBA      = triangle: new (z.I,z.B,z.A)
 z.w        = T.IBA.circumcenter
 L.Ow       = line : new (z.O,z.w)
 _,z.E      = intersection (L.Ow, C.OA)
}
   \begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawArc(J,X)(Y)
   \tkzDrawCircles(I,H O,A)
   \tkzDrawCircle[red](w,I)
   \tkzDrawLines(Y,C A,B X,C E,w E,B)
   \tkzDrawSegments[blue](J,C J,K I,H I,O w,B)
   \tkzDrawPoints(A,B,C,I,J,E,w,H,K,O)
   \tkzLabelPoints(A,B,C,J,I,w,H,K,E,O)
   \tkzMarkRightAngles[fill=gray!20,opacity=.4](C,H,I A,K,J)
   \end{tikzpicture}
\end{Verbatim}

\directlua{%
init_elements ()
z.A       = point: new (0 , 0)
z.B       = point: new (5 , 0)
z.C       = point: new (-.4 , 4)
T.ABC     = triangle: new (z.A,z.B,z.C)
z.J,z.K   = get_points(T.ABC: ex_circle (2))
z.X ,z.Y,z.K  = T.ABC : projection (z.J)
z.I,z.H   = get_points(T.ABC : in_circle())
z.O       = T.ABC.circumcenter
C.OA      = circle : new (z.O,z.A)
T.IBA     = triangle: new (z.I,z.B,z.A)
z.w       = T.IBA.circumcenter
L.Ow      = line : new (z.O,z.w)
_,z.E     = intersection (L.Ow, C.OA)
}

\begin{center}
  \begin{tikzpicture}
  \tkzGetNodes
  \tkzDrawArc(J,X)(Y)
  \tkzDrawCircles(I,H O,A)
  \tkzDrawCircle[red](w,I)
  \tkzDrawLines(Y,C A,B X,C E,w E,B)
  \tkzDrawSegments[blue](J,C J,K I,H I,O w,B)
  \tkzDrawPoints(A,B,C,I,J,E,w,H,K,O)
  \tkzLabelPoints(A,B,C,J,I,w,H,K,E,O)
  \tkzMarkRightAngles[fill=gray!20,opacity=.4](C,H,I A,K,J)
  \end{tikzpicture}
\end{center}

% subsection euler_relation (end)

\subsection{External angle} % (fold)
\label{sub:external_angle}
\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\begin{Verbatim}
\directlua{%
init_elements ()
  z.A    = point: new (0 , 0)
  z.B    = point: new (5 , 0)
  z.C    = point: new (-2 , 4)
  T.ABC  = triangle: new (z.A,z.B,z.C)
  T.ext  = T.ABC: excentral ()
  z.O    = T.ABC.circumcenter
  z.D    = intersection (T.ext.ab,T.ABC.ab)
  z.E    = z.C: symmetry (z.B)
}
\begin{tikzpicture}[cale  = .5]
  \tkzGetNodes
  \tkzDrawPolygon(A,B,C)
  \tkzDrawLine[purple,add=0 and .5](B,C)
  \tkzDrawSegment[purple](A,D)
  \tkzDrawSegment[orange](C,D)
  \tkzFillAngles[purple!30,opacity=.2](D,C,A E,C,D)
  \tkzMarkAngles[mark=|](D,C,A E,C,D)
  \tkzDrawPoints(A,...,D)
  \tkzLabelPoints[above](C)
  \tkzLabelPoints(A,B,D)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\directlua{%
init_elements ()
z.A      = point: new (0 , 0)
z.B      = point: new (5 , 0)
z.C      = point: new (-2 , 4)
T.ABC    = triangle: new (z.A,z.B,z.C)
T.ext    = T.ABC: excentral ()
z.O      = T.ABC.circumcenter
z.D      = intersection (T.ext.ab,T.ABC.ab)
z.E      = z.C: symmetry (z.B)
}


\begin{center}
  \begin{tikzpicture}[scale = .6]
  \tkzGetNodes
  \tkzDrawPolygon(A,B,C)
  \tkzDrawLine[purple,add=0 and .5](B,C)
  \tkzDrawSegment[purple](A,D)
  \tkzDrawSegment[orange](C,D)
  \tkzFillAngles[purple!30,opacity=.2](D,C,A E,C,D)
  \tkzMarkAngles[mark=|](D,C,A E,C,D)
  \tkzDrawPoints(A,...,D)
  \tkzLabelPoints[above](C)
  \tkzLabelPoints(A,B,D)
  \end{tikzpicture}
\end{center}
\end{minipage}
% subsection external_angle (end)

\subsection{Internal angle} % (fold)
\label{sub:internal_angle}
\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\begin{Verbatim}
\directlua{%
init_elements ()
 z.A   = point: new (0 , 0)
 z.B   = point: new (6 , 0)
 z.C   = point: new (1 , 5)
 T     = triangle: new (z.A,z.B,z.C)
 z.I   = T.incenter
 L.AI  = line: new (z.A,z.I)
 z.D   = intersection (L.AI, T.bc)
 L.LL  = T.ab: ll_from (z.C)
 L.AD  = line: new (z.A,z.D)
z.E   = intersection (L.LL,L.AD)
}
\begin{tikzpicture}[scale=.8]
   \tkzGetNodes
   \tkzDrawPolygon(A,B,C)
   \tkzDrawLine[purple](C,E)
   \tkzDrawSegment[purple](A,E)
   \tkzFillAngles[purple!30,opacity=.4](B,A,C C,E,D) 
   \tkzMarkAngles[mark=|](B,A,D D,A,C C,E,D)    
   \tkzDrawPoints(A,...,E) 
   \tkzLabelPoints(A,B)   
   \tkzLabelPoints[above](C,D,E) 
   \tkzMarkSegments(A,C C,E)   
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\directlua{%
init_elements ()
z.A = point: new (0 , 0)
z.B = point: new (6 , 0)
z.C = point: new (1 , 5)
T   = triangle: new (z.A,z.B,z.C)
z.I = T.incenter
L.AI    = line: new (z.A,z.I)
z.D = intersection (L.AI, T.bc)
L.LL    = T.ab: ll_from (z.C)
L.AD    = line: new (z.A,z.D)
z.E = intersection (L.LL,L.AD)
}

\begin{center}
  \begin{tikzpicture}[scale =  .8]
  \tkzGetNodes
  \tkzDrawPolygon(A,B,C)
  \tkzDrawLine[purple](C,E)
  \tkzDrawSegment[purple](A,E)
  \tkzFillAngles[purple!30,opacity=.4](B,A,C C,E,D) 
  \tkzMarkAngles[mark=|](B,A,D D,A,C C,E,D)    
  \tkzDrawPoints(A,...,E) 
  \tkzLabelPoints(A,B)   
  \tkzLabelPoints[above](C,D,E) 
  \tkzMarkSegments(A,C C,E)   
  \end{tikzpicture}
\end{center}

\end{minipage}
%subsection internal_angle (end)

\subsection{Feuerbach theorem} % (fold)
\label{sub:nine_points}


\begin{Verbatim}
\directlua{%
init_elements ()
 z.A     = point: new (0 , 0)
 z.B     = point: new (5 , -.5)
 z.C     = point: new (-.5 , 3)
 T.ABC   = triangle: new (z.A,z.B,z.C)
 z.O     = T.ABC.circumcenter
 z.N     = T.ABC.eulercenter
 z.I,z.K = get_points(T.ABC: in_circle())
 z.H     = T.ABC.ab : projection (z.I)
 z.Ap,
 z.Bp,
 z.Cp  = get_points (T.ABC : medial ())
 C.IH  = circle:new (z.I,z.H)
 C.NAp = circle:new (z.N,z.Ap)
 C.OA  = circle:new (z.O,z.A)
 z.U   = C.OA.south
 z.L   = C.NAp.south
 z.M   = C.NAp.north
 z.X   = T.ABC.ab: projection (z.C)
 L.CU  = line: new (z.C,z.U)
 L.ML  = line: new (z.M,z.L)
 z.P   = L.CU: projection (z.A)
 z.Q   = L.CU: projection (z.B)
 L.LH  = line: new (z.L,z.H)
 z.F   = intersection (L.LH,C.IH) % feuerbach
}

\begin{tikzpicture}[scale = .8]
   \tkzGetNodes
   \tkzDrawLine(L,F)
   \tkzDrawCircle[red](N,A')
   \tkzDrawCircle[blue](I,H)
   \tkzDrawCircles[teal](O,A L,C')
   \tkzDrawSegments(M,L B,U Q,C C,X A,P B,Q)
   \tkzDrawPolygons(A,B,C A',B',C')
   \tkzDrawPoints(A,B,C,N,H,A',B',C',U,L,M,P,Q,F,I)
   \tkzLabelPoints(A,B,C,N,H,A',B',C',U,L,M,P,Q,F,I)
\end{tikzpicture}
\end{Verbatim}

\directlua{%
init_elements ()
z.A    = point: new (0 , 0)
z.B    = point: new (5 , -.5)
z.C    = point: new (-.5 , 3)
T.ABC  = triangle: new (z.A,z.B,z.C)
z.O    = T.ABC.circumcenter
z.N    = T.ABC.eulercenter
z.I,z.K    = get_points(T.ABC: in_circle())
z.H = T.ABC.ab : projection (z.I)
z.Ap,z.Bp,z.Cp = get_points (T.ABC : medial ())
C.IH   = circle:new (z.I,z.H)
C.NAp  = circle:new (z.N,z.Ap)
C.OA   = circle:new (z.O,z.A)
z.U    = C.OA.south
z.L    = C.NAp.south
z.M    = C.NAp.north
z.X    = T.ABC.ab: projection (z.C)
L.CU   = line: new (z.C,z.U)
L.ML   = line: new (z.M,z.L)
z.P    = L.CU: projection (z.A)
z.Q    = L.CU: projection (z.B)
L.LH   = line: new (z.L,z.H)
z.F  = intersection (L.LH,C.IH) % feuerbach
}

\begin{center}
  \begin{tikzpicture}[scale =1.25,rotate=90]
  \tkzGetNodes
  \tkzDrawLine(L,F)
  \tkzDrawCircle[red](N,A')
  \tkzDrawCircle[blue](I,H)
  \tkzDrawCircles[teal](O,A L,C')
  \tkzDrawSegments(M,L B,U Q,C C,X A,P B,Q)
  \tkzDrawPolygons(A,B,C A',B',C')
  \tkzDrawPoints(A,B,C,N,H,A',B',C',U,L,M,P,Q,F,I)
  \tkzLabelPoints(A,B,C,N,H,A',B',C',U,L,M,P,Q,F,I)
  \end{tikzpicture}
\end{center}
   

% subsection nine_points (end)

\subsection{Gold ratio with segment} % (fold)
\label{sub:gold_ratio_with_segment}
\begin{minipage}{.5\textwidth}
 \begin{Verbatim}
\directlua{%
 init_elements ()
 z.A   = point: new (0 , 0)
 z.B   = point: new (6 , 0)
 L.AB  = line: new (z.A,z.B)
 _,_,
 z.X,
 z.Y   = get_points(L.AB: square ())
 L.BX  = line: new (z.B,z.X)
 z.M   = L.BX.mid
 C.MA  = circle: new (z.M,z.A)
 _,z.K = intersection (L.BX,C.MA)
 L.AK  = line: new (z.Y,z.K)
 z.C   = intersection (L.AK,L.AB)
}
\begin{tikzpicture}[scale = .5]
 \tkzGetNodes
 \tkzDrawLines(A,B X,K)
 \tkzDrawLine[teal](Y,K)
 \tkzDrawPoints(A,B,C,X,Y,M,K)
 \tkzDrawArc[delta=20](M,A)(K)
 \tkzLabelPoints(A,B,C)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{%
init_elements ()
z.A = point: new (0 , 0)
z.B = point: new (6 , 0)
L.AB    = line: new (z.A,z.B)
_,_,z.X,z.Y = get_points(L.AB: square ())
L.BX    = line: new (z.B,z.X)
z.M = L.BX.mid
C.MA    = circle: new (z.M,z.A)
_,z.K   = intersection (L.BX,C.MA)
L.AK    = line: new (z.Y,z.K)
z.C = intersection (L.AK,L.AB)
}

\begin{center}
  \begin{tikzpicture}[scale = .5]
  \tkzGetNodes
  \tkzDrawLines(A,B X,K)
  \tkzDrawLine[teal](Y,K)
  \tkzDrawPoints(A,B,C,X,Y,M,K)
  \tkzDrawArc[delta=20](M,A)(K)
  \tkzLabelPoints(A,B,C)
  \end{tikzpicture}
\end{center}

\end{minipage}
%subsection gold_ratio_with_segment (end)

\subsection{Gold Arbelos} % (fold)
\label{sub:gold_arbelos}
\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
 init_elements ()
 z.A      = point: new (0 , 0)
 z.C      = point: new (6 , 0)
 L.AC     = line: new (z.A,z.C)
 _,_,
 z.x,z.y  = get_points(L.AC: square ())
 z.O_1    = L.AC . mid
 C        = circle: new (z.O_1,z.x)
 z.B      = intersection (L.AC,C)
 L.CB     = line: new (z.C,z.B)
 z.O_2    = L.CB.mid
 L.AB     = line: new (z.A,z.B)
 z.O_0    = L.AB.mid
}
\begin{tikzpicture}[ scale    = .6]
 \tkzGetNodes
 \tkzDrawCircles(O_1,C O_2,B O_0,B)
 \tkzDrawPoints(A,C,B,O_1,O_2,O_0)
 \tkzLabelPoints(A,C,B)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{%
init_elements ()
z.A  = point: new (0 , 0)
z.C  = point: new (6 , 0)
L.AC = line: new (z.A,z.C)
_,_,z.x,z.y  = get_points(L.AC: square ())
z.O_1    = L.AC . mid
C    = circle: new (z.O_1,z.x)
z.B  = intersection (L.AC,C)
L.CB = line: new (z.C,z.B)
z.O_2    = L.CB.mid
L.AB = line: new (z.A,z.B)
z.O_0    = L.AB.mid
}
\begin{center}
  \begin{tikzpicture}[scale    = .4]
  \tkzGetNodes
  \tkzDrawCircles(O_1,C O_2,B O_0,B O_1,x)
  \tkzDrawPoints(A,C,B,O_1,O_2,O_0,x)
  \tkzLabelPoints[below right](A,C,B)
  \end{tikzpicture}
\end{center}

\end{minipage}
% subsection gold_arbelos (end)

\subsection{Harmonic division v1} % (fold)
\label{sub:harmonic_division_v1}
\begin{minipage}[t]{.4\textwidth}\vspace{0pt}%
\begin{Verbatim}
\directlua{%
 init_elements ()
 z.A   = point: new (0 , 0)
 z.B   = point: new (4 , 0)
 z.G   = point: new (2,2)
 L.AG  = line : new (z.A,z.G)
 L.AB  = line : new (z.A,z.B)
 z.E   = L.AG : colinear_at (z.B,.5)
 L.GE  = line : new (z.G,z.E)
 z.D   = intersection (L.GE,L.AB)
 z.F   = z.B : symmetry (z.E)
 L.GF  = line :new (z.G,z.F)
 z.C   = intersection (L.GF,L.AB)
}
\begin{tikzpicture}[ scale =.75]
 \tkzGetNodes
 \tkzDrawLines(A,B A,G A,D A,G F,E G,F G,D)
 \tkzDrawPoints(A,B,G,E,F,C,D) 
 \tkzLabelPoints(A,B,G,E,F,C,D)
 \tkzMarkSegments(F,B B,E)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}[t]{.6\textwidth}\vspace{0pt}%
\directlua{%
init_elements ()
 z.A  = point: new (0 , 0)
 z.B  = point: new (4 , 0)
 z.G  = point: new (2,2)
 L.AG = line : new (z.A,z.G)
 L.AB = line : new (z.A,z.B)
 z.E = L.AG : colinear_at (z.B,.5)
 L.GE = line : new (z.G,z.E)
 z.D  = intersection (L.GE,L.AB)
 z.F = z.B : symmetry (z.E)
 L.GF = line :new (z.G,z.F)
 z.C  = intersection (L.GF,L.AB)
}

\begin{center}
  \begin{tikzpicture}[ scale=.75]
   \tkzGetNodes
   \tkzDrawLines(A,B A,G A,D A,G F,E G,F G,D)
   \tkzDrawPoints(A,B,G,E,F,C,D) 
   \tkzLabelPoints(A,B,G,E,F,C,D)
   \tkzMarkSegments(F,B B,E)
  \end{tikzpicture}
\end{center}
\end{minipage}
% subsection harmonic_division_v1 (end)

\subsection{Harmonic division v2} % (fold)
\label{sub:harmonic_division_v2}
\begin{minipage}[t]{.45\textwidth}\vspace{0pt}%
\begin{Verbatim}
\directlua{%
 init_elements ()
 z.A    = point: new (0 , 0)
 z.B    = point: new (6 , 0)
 z.D    = point: new (12 , 0)
 L.AB   = line: new (z.A,z.B)
 z.X    = L.AB.north_pa
 L.XB   = line: new (z.X,z.B)
 z.E    = L.XB.mid
 L.ED   = line: new (z.E,z.D)
 L.AX   = line: new (z.A,z.X)
 L.AE   = line: new (z.A,z.E)
 z.F    = intersection (L.ED,L.AX)
 L.BF   = line: new (z.B,z.F)
 z.G    = intersection (L.AE,L.BF)
 L.GX   = line: new (z.G,z.X)
 z.C    = intersection (L.GX,L.AB)
}
\begin{tikzpicture}[ scale  = .5]
  \tkzGetNodes
  \tkzDrawLines(A,D A,E B,F D,F X,A X,B X,C)
  \tkzDrawPoints(A,...,G,X)
  \tkzLabelPoints(A,...,G,X)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}[t]{.55\textwidth}\vspace{0pt}%
\directlua{%
init_elements ()
z.A    = point: new (0 , 0)
z.B    = point: new (6 , 0)
z.D    = point: new (12 , 0)
L.AB   = line: new (z.A,z.B)
z.X    = L.AB.north_pa
L.XB   = line: new (z.X,z.B)
z.E    = L.XB.mid
L.ED   = line: new (z.E,z.D)
L.AX   = line: new (z.A,z.X)
L.AE   = line: new (z.A,z.E)
z.F    = intersection (L.ED,L.AX)
L.BF   = line: new (z.B,z.F)
z.G    = intersection (L.AE,L.BF)
L.GX   = line: new (z.G,z.X)
z.C    = intersection (L.GX,L.AB)
}

\begin{center}
  \begin{tikzpicture}[scale  = .5]
  \tkzGetNodes
  \tkzDrawLines(A,D A,E B,F D,F X,A X,B X,C)
  \tkzDrawPoints(A,...,G,X)
  \tkzLabelPoints(A,...,G,X)
  \end{tikzpicture}
\end{center}

\end{minipage}
% subsection harmonic_division_v2 (end)

\subsection{Menelaus} % (fold)
\label{sub:menelaus}
\begin{minipage}{.4\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
   z.A  = point: new (0 , 0)
   z.B  = point: new (6 , 0)
   z.C  = point: new (5 , 4)
   z.P  = point: new (-1 , 0)
   z.X  = point: new (6 , 3)
   L.AC = line: new (z.A,z.C)
   L.PX = line: new (z.P,z.X)
   L.BC = line: new (z.B,z.C)
   z.Q  = intersection (L.AC,L.PX)
   z.R  = intersection (L.BC,L.PX)
}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPolygon(A,B,C)
   \tkzDrawLine[new](P,R)
   \tkzDrawLines(P,B A,C B,C)
   \tkzDrawPoints(P,Q,R,A,B,C)
   \tkzLabelPoints(A,B,C,P,Q,R)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.6\textwidth}
\directlua{%
init_elements ()
z.A   = point: new (0 , 0)
z.B   = point: new (6 , 0)
z.C   = point: new (5 , 4)
z.P   = point: new (-1 , 0)
z.X   = point: new (6 , 3)
L.AC  = line: new (z.A,z.C)
L.PX  = line: new (z.P,z.X)
L.BC  = line: new (z.B,z.C)
z.Q   = intersection (L.AC,L.PX)
z.R   = intersection (L.BC,L.PX)
}

\begin{center}
  \begin{tikzpicture}
  \tkzGetNodes
  \tkzDrawPolygon(A,B,C)
  \tkzDrawLine[new](P,R)
  \tkzDrawLines(P,B A,C B,C)
  \tkzDrawPoints(P,Q,R,A,B,C)
  \tkzLabelPoints(A,B,C,P,Q,R)
  \end{tikzpicture}
\end{center}

\end{minipage}
% subsection menelaus (end)


 
\subsection{Euler ellipse} % (fold)
\label{sub:hexagram}
\directlua{%
init_elements ()
z.A        = point: new (2,3.8)
z.B        = point: new (0 ,0)
z.C        = point: new (6.2 ,0)
L.AB       = line : new (z.A,z.B)
T.ABC      = triangle: new (z.A,z.B,z.C)
z.N        = T.ABC.eulercenter
z.G        = T.ABC.centroid
z.O        = T.ABC.circumcenter
z.H        = T.ABC.orthocenter
z.Ma,z.Mb,
z.Mc       = get_points (T.ABC : medial ())
z.Ha,z.Hb,
z.Hc       = get_points (T.ABC : orthic ())   
z.Ea,z.Eb,
z.Ec       = get_points (T.ABC: extouch())
L.euler    = T.ABC : euler_line () 
C.circum   = T.ABC : circum_circle () 
C.euler    = T.ABC : euler_circle () 
z.I,z.J    = intersection (L.euler,C.euler)
local  a   = .5* length(z.I,z.J)
E        = conic : new (EL_bifocal (z.O,z.H,a))
curve      = E : points (0,1,50)
L.AH       = line: new (z.A,z.H)
L.BH       = line: new (z.B,z.H)
L.CH       = line: new (z.C,z.H)
z.X        = intersection (L.AH,C.circum)
_,z.Y      = intersection (L.BH,C.circum)
_,z.Z      = intersection (L.CH,C.circum)
L.BC       = line: new (z.B,z.C)
L.XO       = line: new (z.X,z.O)
L.YO       = line: new (z.Y,z.O)
L.ZO       = line: new (z.Z,z.O)
z.x        = intersection (L.BC,L.XO)
z.U        = intersection (L.XO,E)
_,z.V      = intersection (L.YO,E)
_,z.W      = intersection (L.ZO,E)
}

\begin{minipage}{.4\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
z.A        = point: new (2,3.8)
z.B        = point: new (0 ,0)
z.C        = point: new (6.2 ,0)
L.AB       = line : new (z.A,z.B)
T.ABC      = triangle: new (z.A,z.B,z.C)
z.N        = T.ABC.eulercenter
z.G        = T.ABC.centroid
z.O        = T.ABC.circumcenter
z.H        = T.ABC.orthocenter
z.Ma,z.Mb,
z.Mc       = get_points (T.ABC : medial ())
z.Ha,z.Hb,
z.Hc       = get_points (T.ABC : orthic ())   
z.Ea,z.Eb,
z.Ec       = get_points (T.ABC: extouch())
L.euler    = T.ABC : euler_line () 
C.circum   = T.ABC : circum_circle () 
C.euler    = T.ABC : euler_circle () 
z.I,z.J    = intersection (L.euler,C.euler)
local  a   = .5* length(z.I,z.J)
E          = conic: new (EL_bifocal(z.O,z.H,a))
curve      = E : points (0,1,50)
L.AH       = line: new (z.A,z.H)
L.BH       = line: new (z.B,z.H)
L.CH       = line: new (z.C,z.H)
z.X        = intersection (L.AH,C.circum)
_,z.Y      = intersection (L.BH,C.circum)
_,z.Z      = intersection (L.CH,C.circum)
L.BC       = line: new (z.B,z.C)
L.XO       = line: new (z.X,z.O)
L.YO       = line: new (z.Y,z.O)
L.ZO       = line: new (z.Z,z.O)
z.x        = intersection (L.BC,L.XO)
z.U        = intersection (L.XO,E)
_,z.V      = intersection (L.YO,E)
_,z.W      = intersection (L.ZO,E)
}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.6\textwidth}
\hfill
\begin{tikzpicture}
  \tkzGetNodes
  \tkzDrawPolygon(A,B,C)
  \tkzDrawCircles[red](N,Ma O,A)
  \tkzDrawCoordinates[smooth,cyan](curve)
  \tkzDrawSegments(A,X B,Y C,Z B,Hb C,Hc X,O Y,O Z,O)
  \tkzDrawPolygon[red](U,V,W)
  \tkzLabelPoints[red](U,V,W)
  \tkzLabelPoints(A,B,C,X,Y,Z)
  \tkzDrawLine[blue](I,J)
  \tkzLabelPoints[blue,right](O,N,G,H,I,J)
  \tkzDrawPoints(I,J,U,V,W)
  \tkzDrawPoints(A,B,C,N,G,H,O,X,Y,Z,Ma,Mb,Mc,Ha,Hb,Hc)
\end{tikzpicture}

\end{minipage}

\begin{Verbatim}
\begin{tikzpicture}
  \tkzGetNodes
  \tkzDrawPolygon(A,B,C)
  \tkzDrawCircles[red](N,Ma O,A)
  \tkzDrawCoordinates[smooth,cyan](curve)
  \tkzDrawSegments(A,X B,Y C,Z B,Hb C,Hc X,O Y,O Z,O)
  \tkzDrawPolygon[red](U,V,W)
  \tkzLabelPoints[red](U,V,W)
  \tkzLabelPoints(A,B,C,X,Y,Z)
  \tkzDrawLine[blue](I,J)
  \tkzLabelPoints[blue,right](O,N,G,H,I,J)
  \tkzDrawPoints(I,J,U,V,W)
  \tkzDrawPoints(A,B,C,N,G,H,O,X,Y,Z,Ma,Mb,Mc,Ha,Hb,Hc)
\end{tikzpicture}

\end{Verbatim}

% subsection hexagram (end)

\subsection{Gold Arbelos properties} % (fold)
\label{sub:gold_arbelos_properties}

\directlua{%
init_elements ()
z.A  = point : new(0,0)
z.B  = point : new(10,0)
z.C  = gold_segment_ (z.A,z.B)
L.AB = line:new (z.A,z.B)
z.O_1    = L.AB.mid
L.AC = line:new (z.A,z.C)
z.O_2    = L.AC.mid
L.CB = line:new (z.C,z.B)
z.O_3    = L.CB.mid
C1   = circle:new (z.O_1,z.B)
C2   = circle:new (z.O_2,z.C)
C3   = circle:new (z.O_3,z.B)
z.Q  = C2.north
z.P  = C3.north
L1   = line:new (z.O_2,z.O_3)
z.M_0    = L1:harmonic_ext (z.C)
L2   = line:new (z.O_1,z.O_2)
z.M_1    = L2:harmonic_int (z.A)
L3   = line:new (z.O_1,z.O_3)
z.M_2    = L3:harmonic_int (z.B)
Lbq  = line:new (z.B,z.Q)
Lap  = line:new (z.A,z.P)
z.S  = intersection (Lbq,Lap)
z.x  = z.C: north ()
L    = line : new (z.C,z.x)
z.D,_    = intersection (L,C1)
L.CD = line :new (z.C,z.D)
z.O_7    = L.CD.mid
C.DC = circle: new (z.D,z.C)
z.V,z.U  = intersection (C.DC,C1)
L.UV = line :new (z.U,z.V)
z.R ,z.S = L.UV : projection (z.O_2,z.O_3)
L.O1D    = line : new (z.O_1,z.D)
z.W  = intersection (L.UV,L.O1D)
z.O  = C.DC : inversion (z.W)
}

\begin{minipage}{.4\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
 z.A     = point : new(0,0)
 z.B     = point : new(10,0)
 z.C     = gold_segment_ (z.A,z.B)
 L.AB    = line:new (z.A,z.B)
 z.O_1   = L.AB.mid
 L.AC    = line:new (z.A,z.C)
 z.O_2   = L.AC.mid
 L.CB    = line:new (z.C,z.B)
 z.O_3   = L.CB.mid
 C1      = circle:new (z.O_1,z.B)
 C2      = circle:new (z.O_2,z.C)
 C3      = circle:new (z.O_3,z.B)
 z.Q     = C2.north
 z.P     = C3.north
 L1      = line:new (z.O_2,z.O_3)
 z.M_0   = L1:harmonic_ext (z.C)
 L2      = line:new (z.O_1,z.O_2)
 z.M_1   = L2:harmonic_int (z.A)
 L3      = line:new (z.O_1,z.O_3)
 z.M_2   = L3:harmonic_int (z.B)
 Lbq     = line:new (z.B,z.Q)
 Lap     = line:new (z.A,z.P)
 z.S     = intersection (Lbq,Lap)
 z.x     = z.C: north ()
 L       = line : new (z.C,z.x)
 z.D,_   = intersection (L,C1)
 L.CD    = line :new (z.C,z.D)
 z.O_7   = L.CD.mid
 C.DC    = circle: new (z.D,z.C)
 z.U,z.V = intersection (C.DC,C1)
 L.UV    = line :new (z.U,z.V)
 z.R,z.S = L.UV : projection (z.O_2,z.O_3)
 L.O1D   = line : new (z.O_1,z.D)
 z.W     = intersection (L.UV,L.O1D)
 z.O     = C.DC : inversion (z.W)
}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.6\textwidth}

\begin{center}
  \begin{tikzpicture}[scale = .7]
  \tkzGetNodes
  \tkzDrawCircles[teal](O_1,B)
  \tkzDrawSemiCircles[thin,teal](O_2,C O_3,B)
  \tkzDrawArc[purple,delta=0](D,V)(U)
  \tkzDrawCircle[new](O_7,C)
  \tkzDrawSegments[thin,purple](A,D D,B C,R C,S C,D U,V)
  \tkzDrawSegments[thin,red](O,D A,O O,B)
  \tkzDrawPoints(A,B,C,D,O_7) %,
  \tkzDrawPoints(O_1,O_2,O_3,U,V,R,S,W,O)
  \tkzDrawSegments[cyan](O_3,S O_2,R)
  \tkzDrawSegments[very thin](A,B)
  \tkzDrawSegments[cyan,thin](C,U U,D)
  \tkzMarkRightAngles[size=.2,fill=gray!40,opacity=.4](D,C,A A,D,B
   D,S,C D,W,V O_3,S,U O_2,R,U)
  \tkzFillAngles[cyan!40,opacity=.4](B,A,D A,D,O_1
   C,D,B D,C,R B,C,S A,R,O_2)
  \tkzFillAngles[green!40,opacity=.4](S,C,D W,R,D
   D,B,C R,C,A O_3,S,B)
  \tkzLabelPoints[below](C,O_2,O_3,O_1)
  \tkzLabelPoints[above](D)
  \tkzLabelPoints[below](O)
  \tkzLabelPoints[below left](A)
  \tkzLabelPoints[above left](R)
  \tkzLabelPoints[above right](S)
  \tkzLabelPoints[left](V)
  \tkzLabelPoints[below right](B,U,W,O_7)
  \end{tikzpicture}
\end{center}


\end{minipage}

\begin{Verbatim}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawCircles[teal](O_1,B)
   \tkzDrawSemiCircles[thin,teal](O_2,C O_3,B)
   \tkzDrawArc[purple,delta=0](D,V)(U)
   \tkzDrawCircle[new](O_7,C)
   \tkzDrawSegments[thin,purple](A,D D,B C,R C,S C,D U,V)
   \tkzDrawSegments[thin,red](O,D A,O O,B)
   \tkzDrawPoints(A,B,C,D,O_7) %,
   \tkzDrawPoints(O_1,O_2,O_3,U,V,R,S,W,O)
   \tkzDrawSegments[cyan](O_3,S O_2,R)
   \tkzDrawSegments[very thin](A,B)
   \tkzDrawSegments[cyan,thin](C,U U,D)
   \tkzMarkRightAngles[size=.2,fill=gray!40,opacity=.4](D,C,A A,D,B
     D,S,C D,W,V O_3,S,U O_2,R,U)
   \tkzFillAngles[cyan!40,opacity=.4](B,A,D A,D,O_1
     C,D,B D,C,R B,C,S A,R,O_2)
   \tkzFillAngles[green!40,opacity=.4](S,C,D W,R,D
     D,B,C R,C,A O_3,S,B)
   \tkzLabelPoints[below](C,O_2,O_3,O_1)
   \tkzLabelPoints[above](D)
   \tkzLabelPoints[below](O)
   \tkzLabelPoints[below left](A)
   \tkzLabelPoints[above left](R)
   \tkzLabelPoints[above right](S)
   \tkzLabelPoints[left](V)
   \tkzLabelPoints[below right](B,U,W,O_7)
\end{tikzpicture}
\end{Verbatim}
% subsection gold_arbelos_properties (end)

\subsection{Apollonius circle v1 with inversion} % (fold)
\label{sub:apollonius_circle_v1_with_inversion}
\begin{Verbatim}
\directlua{%
init_elements ()
   z.A               = point: new (0,0)
   z.B               = point: new (6,0)
   z.C               = point: new (0.8,4)
   T.ABC             = triangle : new ( z.A,z.B,z.C )
   z.N               = T.ABC.eulercenter
   z.Ea,z.Eb,z.Ec    = get_points ( T.ABC : feuerbach () )
   z.Ja,z.Jb,z.Jc    = get_points ( T.ABC : excentral () )
   z.S               = T.ABC : spieker_center ()
   C.JaEa            = circle : new (z.Ja,z.Ea)
   C.ortho           = circle : radius (z.S,math.sqrt(C.JaEa : power (z.S) ))
   z.a               = C.ortho.south
   C.euler           = T.ABC: euler_circle ()
   C.apo             = C.ortho : inversion (C.euler)
   z.O               = C.apo.center
   z.xa,z.xb,z.xc    = C.ortho : inversion (z.Ea,z.Eb,z.Ec)
}
\begin{tikzpicture}[scale= .7]
   \tkzGetNodes
\tkzDrawCircles[red](O,xa N,Ea)
\tkzFillCircles[green!30!black,opacity=.3](O,xa)
\tkzFillCircles[yellow!30,opacity=.7](Ja,Ea Jb,Eb Jc,Ec)
\tkzFillCircles[teal!30!black,opacity=.3](S,a)
\tkzFillCircles[green!30,opacity=.3](N,Ea)
\tkzDrawPoints[red](Ea,Eb,Ec,xa,xb,xc,N)
\tkzClipCircle(O,xa)
\tkzDrawLines[add=3 and 3](A,B A,C B,C)
\tkzDrawCircles(Ja,Ea Jb,Eb Jc,Ec)
\tkzFillCircles[lightgray!30,opacity=.7](Ja,Ea Jb,Eb Jc,Ec)
\tkzDrawCircles[teal](S,a)
\tkzDrawPoints(A,B,C,O)
\tkzDrawPoints[teal](S)
\tkzLabelPoints(A,B,C,O,S,N)
\end{tikzpicture}
\end{Verbatim}

\directlua{%
init_elements ()
   z.A               = point: new (0,0)
   z.B               = point: new (6,0)
   z.C               = point: new (0.8,4)
   T.ABC             = triangle : new ( z.A,z.B,z.C )
   z.N               = T.ABC.eulercenter
   z.Ea,z.Eb,z.Ec    = get_points ( T.ABC : feuerbach () )
   z.Ja,z.Jb,z.Jc    = get_points ( T.ABC : excentral () )
   z.S               = T.ABC : spieker_center ()
   C.JaEa            = circle : new (z.Ja,z.Ea)
   C.ortho           = circle : radius (z.S,math.sqrt(C.JaEa : power (z.S) ))
   z.a               = C.ortho.south
   C.euler           = T.ABC: euler_circle ()
   C.apo             = C.ortho : inversion (C.euler)
   z.O               = C.apo.center
   z.xa,z.xb,z.xc    = C.ortho : inversion (z.Ea,z.Eb,z.Ec)
}

\begin{center}
  \begin{tikzpicture}[scale= .5]
     \tkzGetNodes
  \tkzDrawCircles[red](O,xa N,Ea)
  \tkzFillCircles[green!30!black,opacity=.3](O,xa)
  \tkzFillCircles[yellow!30,opacity=.7](Ja,Ea Jb,Eb Jc,Ec)
  \tkzFillCircles[teal!30!black,opacity=.3](S,a)
  \tkzFillCircles[green!30,opacity=.3](N,Ea)
  \tkzDrawPoints[red](Ea,Eb,Ec,xa,xb,xc,N)
  \tkzClipCircle(O,xa)
  \tkzDrawLines[add=3 and 3](A,B A,C B,C)
  \tkzDrawCircles(Ja,Ea Jb,Eb Jc,Ec)
  \tkzFillCircles[lightgray!30,opacity=.7](Ja,Ea Jb,Eb Jc,Ec)
  \tkzDrawCircles[teal](S,a)
  \tkzDrawPoints(A,B,C,O)
  \tkzDrawPoints[teal](S)
  \tkzLabelPoints(A,B,C,O,S,N)
  \end{tikzpicture}
\end{center}


% subsection apollonius_circle_v1_with_inversion (end)

\subsection{Apollonius circle v2} % (fold)
\label{sub:apollonius_circle_v2}
\begin{Verbatim}
\directlua{%
init_elements ()
   z.A         = point: new (0,0)
   z.B         = point: new (6,0)
   z.C         = point: new (0.8,4)
   T.ABC       = triangle: new(z.A,z.B,z.C)
   z.O         = T.ABC.circumcenter
   z.H         = T.ABC.orthocenter
   z.G         = T.ABC.centroid
   z.L         = T.ABC: lemoine_point ()
   z.S         = T.ABC: spieker_center ()
   C.euler     = T.ABC: euler_circle ()
   z.N,z.Ma    = get_points (C.euler)
   C.exA       = T.ABC : ex_circle ()
   z.Ja,z.Xa   = get_points (C.exA)
   C.exB       = T.ABC : ex_circle (1)
   z.Jb,z.Xb   = get_points (C.exB)
   C.exC       = T.ABC : ex_circle (2)
   z.Jc,z.Xc   = get_points (C.exC)
   L.OL        = line: new (z.O,z.L)
   L.NS        = line: new (z.N,z.S)
   z.o         = intersection (L.OL,L.NS) % center of Apollonius circle
   L.NMa       = line: new (z.N,z.Ma)
   L.ox        = L.NMa: ll_from (z.o)
   L.MaS       = line: new (z.Ma,z.S)
   z.t         = intersection (L.ox,L.MaS) % through
}

\begin{tikzpicture}[scale= .5]
   \tkzGetNodes
   \tkzDrawLines[add=1 and 1](A,B A,C B,C)
   \tkzDrawCircles(Ja,Xa Jb,Xb Jc,Xc o,t N,Ma) %
   \tkzClipCircle(o,t)
   \tkzDrawLines[red](o,L N,o Ma,t)
   \tkzDrawLines[cyan,add=4 and 4](Ma,N o,t)
   \tkzDrawPoints(A,B,C,Ma,Ja,Jb,Jc)
   \tkzDrawPoints[red](N,O,L,S,o,t)
   \tkzLabelPoints[right,font=\tiny](A,B,C,Ja,Jb,Jc,O,N,L,S,Ma,o)
\end{tikzpicture}
\end{Verbatim}

\directlua{%
init_elements ()
z.A    = point: new (0,0)
z.B    = point: new (6,0)
z.C    = point: new (0.8,4)
T.ABC  = triangle: new(z.A,z.B,z.C)
z.O    = T.ABC.circumcenter
z.H    = T.ABC.orthocenter
z.G    = T.ABC.centroid
z.L    = T.ABC: lemoine_point ()
z.S    = T.ABC: spieker_center ()
C.euler    = T.ABC: euler_circle ()
z.N,z.Ma   = get_points (C.euler)
C.exA  = T.ABC : ex_circle ()
z.Ja,z.Xa  = get_points (C.exA)
C.exB  = T.ABC : ex_circle (1)
z.Jb,z.Xb  = get_points (C.exB)
C.exC  = T.ABC : ex_circle (2)
z.Jc,z.Xc  = get_points (C.exC)
L.OL   = line: new (z.O,z.L)
L.NS   = line: new (z.N,z.S)
z.o    = intersection (L.OL,L.NS) % center of Apollonius circle
L.NMa  = line: new (z.N,z.Ma)
L.ox   = L.NMa: ll_from (z.o)
L.MaS  = line: new (z.Ma,z.S)
z.t    = intersection (L.ox,L.MaS) % through
}

\begin{center}
  \begin{tikzpicture}[scale =.5]
  \tkzGetNodes
  \tkzDrawLines[add=1 and 1](A,B A,C B,C)
  \tkzDrawCircles(Ja,Xa Jb,Xb Jc,Xc o,t N,Ma) 
  \tkzClipCircle(o,t)
  \tkzDrawLines[red](o,L N,o Ma,t)
  \tkzDrawLines[cyan,add=4 and 4](Ma,N o,t)
  \tkzDrawPoints(A,B,C,Ma,Ja,Jb,Jc)
  \tkzDrawPoints[red](N,O,L,S,o,t)
  \tkzLabelPoints[right,font=\tiny](A,B,C,Ja,Jb,Jc,O,N,L,S,Ma,o)
  \end{tikzpicture}
\end{center}
% subsection apollonius_circle_v2 (end)



\subsection{Orthogonal circles} % (fold)
\label{sub:orthogonal_circles_v2}

\begin{minipage}{.5\textwidth}
  \begin{Verbatim}
  \directlua{%
  init_elements ()
  z.O      = point: new (2,2)
  z.Op     = point: new (-4,1)
  z.P      = point: polar (4,0)
  C.OP     = circle: new (z.O,z.P)
  C.Oz1    =  C.OP : orthogonal_from (z.Op)
  z.z1     = C.Oz1.through
  L.OP     = line : new (z.O,z.P)
  C.Opz1   = circle: new (z.Op,z.z1)
  L.T,L.Tp = C.Opz1 : tangent_from (z.O)
  z.T      = L.T.pb
  z.Tp     = L.Tp.pb
  L.OOp    = line : new (z.O,z.Op)
  z.M      = L.OOp.mid
  }
  \begin{tikzpicture}[ scale = .5]
     \tkzGetNodes
     \tkzDrawCircle[red](O,P)
     \tkzDrawCircle[purple](O',z1)
     \tkzDrawCircle[cyan](M,T)
     \tkzDrawSegments(O',T O,T' O',T')
     \tkzDrawSegment[purple](O',T)
     \tkzDrawSegments[red](O,T O,O')
     \tkzDrawPoints(O,O',T,T',M)
     \tkzMarkRightAngle[fill=gray!10](O',T,O)
     \tkzLabelPoint[below](O){$O$}
     \tkzLabelPoint[above](T){$T$}
     \tkzLabelPoint[above](M){$M$}
     \tkzLabelPoint[below](T'){$T'$}
     \tkzLabelPoint[above left](O'){$O'$}
  \end{tikzpicture}
  \end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
  \directlua{%
  init_elements ()
  z.O      = point: new (2,2)
  z.Op     = point: new (-4,1)
  z.P      = point: polar (4,0)
  C.OP     = circle: new (z.O,z.P)
  C.Oz1    =  C.OP : orthogonal_from (z.Op)
  z.z1     = C.Oz1.through
  L.OP     = line : new (z.O,z.P)
  C.Opz1   = circle: new (z.Op,z.z1)
  L.T,L.Tp = C.Opz1 : tangent_from (z.O)
  z.T      = L.T.pb
  z.Tp     = L.Tp.pb
  L.OOp    = line : new (z.O,z.Op)
  z.M      = L.OOp.mid
  }

  \begin{center}
    \begin{tikzpicture}[ scale = .5]
    \tkzGetNodes
    \tkzDrawCircle[red](O,P)
    \tkzDrawCircle[purple](O',z1)
    \tkzDrawCircle[cyan](M,T)
    \tkzDrawSegments(O',T O,T' O',T')
    \tkzDrawSegment[purple](O',T)
    \tkzDrawSegments[red](O,T O,O')
    \tkzDrawPoints(O,O',T,T',M)
    \tkzMarkRightAngle[fill=gray!10](O',T,O)
    \tkzLabelPoint[below](O){$O$}
    \tkzLabelPoint[above](T){$T$}
    \tkzLabelPoint[above](M){$M$}
    \tkzLabelPoint[below](T'){$T'$}
    \tkzLabelPoint[above left](O'){$O'$}
    \end{tikzpicture}
  \end{center}
\end{minipage}



% subsection orthogonal_circles_v2 (end)
%
\subsection{Orthogonal circle to two circles} % (fold)
\label{sub:orthogonal_circle_to_two_circles}

\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
 z.O      = point :   new (-1,0)
 z.B      = point :   new (0,2)
 z.Op     = point :   new (4,-1)
 z.D      = point :   new (4,0)
 C.OB     = circle :  new (z.O,z.B)
 C.OpD    = circle :  new (z.Op,z.D)
 z.E,z.F  = get_points (C.OB : radical_axis (C.OpD))
 L.EF     = line : new (z.E,z.F)
 z.M      = L.EF : point (.25)
 L.T,L.Tp = C.OB : tangent_from (z.M)
 L.K,L.Kp = C.OpD : tangent_from (z.M)
 z.T      = L.T.pb
 z.K      = L.K.pb
 z.Tp     = L.Tp.pb
 z.Kp     = L.Kp.pb
}
\begin{tikzpicture}[scale =.75]
   \tkzGetNodes
   \tkzDrawCircles(O,B O',D)
   \tkzDrawLine[cyan](E,F)
   \tkzDrawLines[add=.5 and .5,orange](O,O' O,T O,T')
   \tkzDrawSegments[cyan](M,T M,T' M,K M,K')
   \tkzDrawCircle(M,T)
   \tkzDrawPoints(O,O',T,M,T',K,K')
   \tkzLabelPoints(O,O',T,T',M,K,K')
\end{tikzpicture}
  \end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{%
init_elements ()
z.O   = point :   new (-1,0)
z.B   = point :   new (0,2)
z.Op  = point :   new (4,-1)
z.D   = point :   new (4,0)
C.OB  = circle :  new (z.O,z.B)
C.OpD = circle :  new (z.Op,z.D)
z.E,z.F   = get_points (C.OB : radical_axis (C.OpD))
L.EF  = line : new (z.E,z.F)
z.M   = L.EF : point (.25)
L.T,L.Tp  = C.OB : tangent_from (z.M)
L.K,L.Kp  = C.OpD : tangent_from (z.M)
z.T = L.T.pb
z.K = L.K.pb
z.Tp = L.Tp.pb
z.Kp = L.Kp.pb
}
\begin{center}
  \begin{tikzpicture}[scale = .75]
  \tkzGetNodes
  \tkzDrawCircles(O,B O',D)
  \tkzDrawLine[cyan](E,F)
  \tkzDrawLines[add=.5 and .5,orange](O,O' O,T O,T')
  \tkzDrawSegments[cyan](M,T M,T' M,K M,K')
  \tkzDrawCircle(M,T)
  \tkzDrawPoints(O,O',T,M,T',K,K')
  \tkzLabelPoints(O,O',T,T',M,K,K')
  \end{tikzpicture}
\end{center}
\end{minipage}

% subsection Orthogonal to two circles (fold)

\subsection{Midcircles} % (fold)
\label{sub:midcircles}

\directlua{%
init_elements ()
z.A  = point: new (0 , 0)
z.B  = point: new (10 , 0)
L.AB = line : new (z.A,z.B)
z.C  = L.AB: gold_ratio ()
L.AC = line : new (z.A,z.C)
L.CB = line : new (z.C,z.B)
z.O_0    = L.AB.mid
z.O_1    = L.AC.mid
z.O_2    = L.CB.mid
C.O0B    = circle : new (z.O_0,z.B)
C.O1C    = circle : new (z.O_1,z.C)
C.O2C    = circle : new (z.O_2,z.B)
z.Q  = C.O1C : midarc (z.C,z.A)
z.P  = C.O2C : midarc (z.B,z.C)
L.O1O2   = line : new (z.O_1,z.O_2)
L.O0O1   = line : new (z.O_0,z.O_1)
L.O0O2   = line : new (z.O_0,z.O_2)
z.M_0    = L.O1O2 : harmonic_ext (z.C)
z.M_1    = L.O0O1 : harmonic_int (z.A)
z.M_2    = L.O0O2 : harmonic_int (z.B)
L.BQ = line : new (z.B,z.Q)
L.AP = line : new (z.A,z.P)
z.S  = intersection (L.BQ,L.AP)
L.CS = line : new (z.C,z.S)
C.M1A    = circle : new (z.M_1,z.A)
C.M2B    = circle : new (z.M_2,z.B)
z.P_0    = intersection (L.CS,C.O0B)
z.P_1    = intersection (C.M2B,C.O1C)
z.P_2    = intersection (C.M1A,C.O2C)
T.P012   = triangle : new (z.P_0,z.P_1,z.P_2)
z.O_4    = T.P012.circumcenter
T.CP12   = triangle : new (z.C,z.P_1,z.P_2)
z.O_5    = T.CP12.circumcenter
z.BN = z.B : north ()
L.BBN    = line : new (z.B,z.BN)
L.M1P2   = line : new (z.M_1,z.P_2)
z.J  = intersection (L.BBN,L.M1P2)
L.AP0    = line : new (z.A,z.P_0)
L.BP0    = line : new (z.B,z.P_0)
C.O4P0   = circle : new (z.O_4,z.P_0)
_,z.G  = intersection (L.AP0,C.O4P0)
z.H    = intersection (L.BP0,C.O4P0)
z.Ap = z.M_1: symmetry (z.A)
z.H_4,z.F,z.E,z.H_0 = L.AB : projection (z.O_4,z.G,z.H,z.P_0)
}


\begin{center}
  \begin{tikzpicture}
  \tkzGetNodes
  \tkzDrawCircle[thin,fill=green!10](O_4,P_0)
  \tkzDrawCircle[purple,fill=purple!10,opacity=.5](O_5,C)
  \tkzDrawSemiCircles[teal](O_0,B)
  \tkzDrawSemiCircles[thin,teal,fill=teal!20,opacity=.5](O_1,C O_2,B)
  \tkzDrawSemiCircles[color = orange](M_2,B)
  \tkzDrawSemiCircles[color = orange](M_1,A')
  \tkzDrawArc[purple,delta=0](M_0,P_0)(C)
  \tkzDrawSegments[very thin](A,B A,P B,Q)
  \tkzDrawSegments[color=cyan](O_0,P_0 B,J G,J G,O_0 H,O_2)
  \tkzDrawSegments[ultra thin,purple](M_1,P_0 M_2,P_0 M_1,M_0 M_0,P_1 M_0,P_0 M_1,J)
  \tkzDrawPoints(A,B,C,P_0,P_2,P_1,M_0,M_1,M_2,J,P,Q,S)
  \tkzDrawPoints(O_0,O_1,O_2,O_4,O_5,G,H)
  \tkzMarkRightAngle[size=.2,fill=gray!20,opacity=.4](O_0,P_0,M_0)
  \tkzLabelPoints[below](A,B,C,M_0,M_1,M_2,O_1,O_2,O_0)
  \tkzLabelPoints[above](P_0,O_5,O_4)
  \tkzLabelPoints[above](P_1,J)
  \tkzLabelPoints[above](P_2,P,Q,S)
  \tkzLabelPoints[above right](H,E)
  \tkzLabelPoints[above left](F,G)
  \tkzLabelPoints[below right](H_0)
  \tkzLabelCircle[below=4pt,font=\scriptsize](O_1,C)(80){$(\beta)$}
  \tkzLabelCircle[below=4pt,font=\scriptsize](O_2,B)(80){$(\gamma)$}
  \tkzLabelCircle[below=4pt,font=\scriptsize](O_0,B)(110){$(\alpha)$}
  \tkzLabelCircle[left,font=\scriptsize](O_4,P_2)(60){$(\delta)$}
  \tkzLabelCircle[above left,font=\scriptsize](O_5,C)(40){$(\epsilon)$}
  \end{tikzpicture}
\end{center}



\begin{Verbatim}
\directlua{%
init_elements ()
   z.A      = point: new (0 , 0)
   z.B      = point: new (10 , 0)
   L.AB     = line : new (z.A,z.B)
   z.C      = L.AB: gold_ratio ()
   L.AC     = line : new (z.A,z.C)
   L.CB     = line : new (z.C,z.B)
   z.O_0    = L.AB.mid
   z.O_1    = L.AC.mid
   z.O_2    = L.CB.mid
   C.O0B    = circle : new (z.O_0,z.B)
   C.O1C    = circle : new (z.O_1,z.C)
   C.O2C    = circle : new (z.O_2,z.B)
   z.Q      = C.O1C : midarc (z.C,z.A)
   z.P      = C.O2C : midarc (z.B,z.C)
   L.O1O2   = line : new (z.O_1,z.O_2)
   L.O0O1   = line : new (z.O_0,z.O_1)
   L.O0O2   = line : new (z.O_0,z.O_2)
   z.M_0    = L.O1O2 : harmonic_ext (z.C)
   z.M_1    = L.O0O1 : harmonic_int (z.A)
   z.M_2    = L.O0O2 : harmonic_int (z.B)
   L.BQ     = line : new (z.B,z.Q)
   L.AP     = line : new (z.A,z.P)
   z.S      = intersection (L.BQ,L.AP)
   L.CS     = line : new (z.C,z.S)
   C.M1A    = circle : new (z.M_1,z.A)
   C.M2B    = circle : new (z.M_2,z.B)
   z.P_0    = intersection (L.CS,C.O0B)
   z.P_1    = intersection (C.M2B,C.O1C)
   z.P_2    = intersection (C.M1A,C.O2C)
   T.P012   = triangle : new (z.P_0,z.P_1,z.P_2)
   z.O_4    = T.P012.circumcenter
   T.CP12   = triangle : new (z.C,z.P_1,z.P_2)
   z.O_5    = T.CP12.circumcenter
   z.BN     = z.B : north ()
   L.BBN    = line : new (z.B,z.BN)
   L.M1P2   = line : new (z.M_1,z.P_2)
   z.J      = intersection (L.BBN,L.M1P2)
   L.AP0    = line : new (z.A,z.P_0)
   L.BP0    = line : new (z.B,z.P_0)
   C.O4P0   = circle : new (z.O_4,z.P_0)
   _,z.G    = intersection (L.AP0,C.O4P0)
   z.H      = intersection (L.BP0,C.O4P0)
   z.Ap     = z.M_1: symmetry (z.A)
   z.H_4,z.F,z.E,z.H_0 = L.AB : projection (z.O_4,z.G,z.H,z.P_0)
}
\end{Verbatim}

\begin{Verbatim}
\begin{tikzpicture}
\tkzGetNodes
\tkzDrawCircle[thin,fill=green!10](O_4,P_0)
\tkzDrawCircle[purple,fill=purple!10,opacity=.5](O_5,C)
\tkzDrawSemiCircles[teal](O_0,B)
\tkzDrawSemiCircles[thin,teal,fill=teal!20,opacity=.5](O_1,C O_2,B)
\tkzDrawSemiCircles[color = orange](M_2,B)
\tkzDrawSemiCircles[color = orange](M_1,A')
\tkzDrawArc[purple,delta=0](M_0,P_0)(C)
\tkzDrawSegments[very thin](A,B A,P B,Q)
\tkzDrawSegments[color=cyan](O_0,P_0 B,J G,J G,O_0 H,O_2)
\tkzDrawSegments[ultra thin,purple](M_1,P_0 M_2,P_0 M_1,M_0 M_0,P_1 M_0,P_0 M_1,J)
\tkzDrawPoints(A,B,C,P_0,P_2,P_1,M_0,M_1,M_2,J,P,Q,S)
\tkzDrawPoints(O_0,O_1,O_2,O_4,O_5,G,H)
\tkzMarkRightAngle[size=.2,fill=gray!20,opacity=.4](O_0,P_0,M_0)
\tkzLabelPoints[below](A,B,C,M_0,M_1,M_2,O_1,O_2,O_0)
\tkzLabelPoints[above](P_0,O_5,O_4)
\tkzLabelPoints[above](P_1,J)
\tkzLabelPoints[above](P_2,P,Q,S)
\tkzLabelPoints[above right](H,E)
\tkzLabelPoints[above left](F,G)
\tkzLabelPoints[below right](H_0)
\tkzLabelCircle[below=4pt,font=\scriptsize](O_1,C)(80){$(\beta)$}
\tkzLabelCircle[below=4pt,font=\scriptsize](O_2,B)(80){$(\gamma)$}
\tkzLabelCircle[below=4pt,font=\scriptsize](O_0,B)(110){$(\alpha)$}
\tkzLabelCircle[left,font=\scriptsize](O_4,P_2)(60){$(\delta)$}
\tkzLabelCircle[above left,font=\scriptsize](O_5,C)(40){$(\epsilon)$}
\end{tikzpicture}
\end{Verbatim}


% subsection midcircles (end)

\subsection{Pencil v1} % (fold)
\label{sub:pencil_v1}
\begin{Verbatim}
\directlua{%
init_elements ()
   z.A         = point : new (0,2)
   z.B         = point : new (0,-2)
   z.C_0       = point : new (-3,0)
   z.C_1       = point : new (2,0)
   z.C_3       = point : new (2.5,0)
   z.C_5       = point : new (1,0)
   L.BA        = line : new (z.B,z.A)
   z.M_0       = L.BA : point (1.25)
   z.M_1       = L.BA : point (1.5)
   C.C0A       = circle :    new (z.C_0,z.A)
   z.x,z.y     = get_points (C.C0A : orthogonal_from (z.M_0))
   z.xp,z.yp   = get_points (C.C0A : orthogonal_from (z.M_1))
   z.O         = L.BA.mid
}
\end{Verbatim}

\directlua{%
init_elements ()
z.A     = point : new (0,2)
z.B     = point : new (0,-2)
z.C_0   = point : new (-3,0)
z.C_1   = point : new (2,0)
z.C_3   = point : new (2.5,0)
z.C_5   = point : new (1,0)
L.BA    = line : new (z.B,z.A)
z.M_0   = L.BA : point (1.25)
z.M_1   = L.BA : point (1.5)
C.C0A   = circle :    new (z.C_0,z.A)
z.x,z.y = get_points (C.C0A : orthogonal_from (z.M_0))
z.xp,z.yp   = get_points (C.C0A : orthogonal_from (z.M_1))
z.O     = L.BA.mid
}

\begin{center}
  \begin{tikzpicture}[scale=.75]
  \tkzGetNodes
  \tkzDrawCircles(C_0,A C_1,A C_3,A C_5,A)
  \tkzDrawCircles[thick,color=red](M_0,x M_1,x')
  \tkzDrawCircles[thick,color=blue](O,A)
  \tkzDrawLines(C_0,C_1 B,M_1)
  \tkzDrawPoints(A,B,C_0,C_1,M_0,M_1,x,y)
  \tkzLabelPoints[below right](A,B,C_0,C_1,M_0,M_1,x,y)
  \tkzLabelLine[pos=1.25,right]( M_0,M_1){$(\Delta)$}
  \end{tikzpicture}
\end{center}

\begin{Verbatim}
  \begin{tikzpicture}[scale=.75]
  \tkzGetNodes
  \tkzDrawCircles(C_0,A C_1,A C_3,A C_5,A)
  \tkzDrawCircles[thick,color=red](M_0,x M_1,x')
  \tkzDrawCircles[thick,color=blue](O,A)
  \tkzDrawLines(C_0,C_1 B,M_1)
  \tkzDrawPoints(A,B,C_0,C_1,M_0,M_1,x,y)
  \tkzLabelPoints[below right](A,B,C_0,C_1,M_0,M_1,x,y)
  \tkzLabelLine[pos=1.25,right]( M_0,M_1){$(\Delta)$}
  \end{tikzpicture}
\end{Verbatim}

% subsection pencil_v1 (end)

\subsection{Pencil v2} % (fold)
\label{sub:pencil_v2}
\begin{Verbatim}
\directlua{%
init_elements ()
   z.A     = point : new (0,0)
   z.B     = point : new (1,0)
   z.C_0   = point : new (-2,0)
   z.C_1   = point : new (4,0)
   C.C0A   = circle : new (z.C_0,z.A)
   C.C1B   = circle : new (z.C_1,z.B)
   L.EF    = C.C0A : radical_axis (C.C1B)
   z.M_0   = L.EF : point (.4)
   z.M_1   = L.EF : point (.1)
   z.M_2   = L.EF : point (.6)
   C.orth0     = C.C0A : orthogonal_from (z.M_0)
   C.orth1     = C.C0A : orthogonal_from (z.M_1)
   C.orth2     = C.C0A : orthogonal_from (z.M_2)
   z.u         = C.orth0.through
   z.v         = C.orth1.through
   z.t         = C.orth2.through
}
\end{Verbatim}

\directlua{%
init_elements ()
   z.A     = point : new (0,0)
   z.B     = point : new (1,0)
   z.C_0   = point : new (-2,0)
   z.C_1   = point : new (4,0)
   C.C0A   = circle :    new (z.C_0,z.A)
   C.C1B   = circle : new (z.C_1,z.B)
   L.EF    = C.C0A : radical_axis (C.C1B)
   z.M_0   = L.EF : point (.4)
   z.M_1   = L.EF : point (.1)
   z.M_2   = L.EF : point (.6)
   C.orth0     = C.C0A : orthogonal_from (z.M_0)
   C.orth1     = C.C0A : orthogonal_from (z.M_1)
   C.orth2     = C.C0A : orthogonal_from (z.M_2)
   z.u         = C.orth0.through
   z.v         = C.orth1.through
   z.t         = C.orth2.through
}

\begin{center}
  \begin{tikzpicture}[scale=.75]
  \tkzGetNodes
  \tkzDrawCircles(C_0,A C_1,B)
  \tkzDrawCircles[thick,color=red](M_0,u M_1,v M_2,t)
  \tkzDrawLines[add= .75 and .75](C_0,C_1 M_0,M_1)
  \tkzDrawPoints(A,B,C_0,C_1,M_0,M_1,M_2)
  \tkzLabelPoints[below right](A,B,C_0,C_1,M_0,M_1,M_2)
  \tkzLabelLine[pos=2,right]( M_0,M_1){$(\Delta)$}
  \end{tikzpicture}
\end{center}

\begin{Verbatim}
\begin{tikzpicture}[scale=.75]
   \tkzGetNodes
   \tkzDrawCircles(C_0,A C_1,B)
   \tkzDrawCircles[thick,color=red](M_0,u M_1,v M_2,t)
   \tkzDrawLines[add= .75 and .75](C_0,C_1 M_0,M_1)
   \tkzDrawPoints(A,B,C_0,C_1,M_0,M_1,M_2)
   \tkzLabelPoints[below right](A,B,C_0,C_1,M_0,M_1,M_2)
   \tkzLabelLine[pos=2,right]( M_0,M_1){$(\Delta)$}
\end{tikzpicture}
\end{Verbatim}

%subsection pencil_v2 (end)


\subsection{Reim v1} % (fold)
\label{sub:reim_v1}

\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
 z.A   = point: new (0,0)
 z.E   = point: new (-2,2)
 C.AE  = circle : new (z.A,z.E)
 z.C   = C.AE : point (0.65)
 z.D   = C.AE : point (0.5)
 z.F   = C.AE : point (0.30)
 L.EC  = line: new (z.E,z.C)
 z.H   = L.EC : point (1.5)
 T.CDH = triangle : new (z.C,z.D,z.H)
 z.B   = T.CDH.circumcenter
 C.BD  = circle : new (z.B,z.D)
 L.FD  = line: new (z.F,z.D)
 z.G   = intersection (L.FD,C.BD)
 z.O   = intersection (L.EC,L.FD)
}
\begin{tikzpicture}
 \tkzGetNodes
 \tkzDrawCircles(A,E B,H)
 \tkzDrawSegments(E,D C,F)
 \tkzDrawLines(E,O F,O)
 \tkzDrawLines[red](E,F H,G)
 \tkzDrawPoints(A,...,H,O)
 \tkzLabelPoints(A,B,D,F,G,O)
 \tkzLabelPoints[above](E,C,H)
 \tkzMarkAngles[size=.5](E,C,F E,D,F)
 \tkzFillAngles[green!40,opacity=.4,size=.5](E,C,F E,D,F)
 \tkzMarkAngles[size=.5](F,C,H G,D,E)
 \tkzFillAngles[red!40,opacity=.4,size=.5](F,C,H G,D,E)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
  \directlua{%
  init_elements ()
     z.A     = point: new (0,0)
     z.E     = point: new (-2,2)
     C.AE    = circle :   new (z.A,z.E)
     z.C     = C.AE : point (0.65)
     z.D     = C.AE : point (0.5)
     z.F     = C.AE : point (0.30)
     L.EC    = line: new (z.E,z.C)
     z.H     = L.EC : point (1.5)
     T.CDH   = triangle : new (z.C,z.D,z.H)
     z.B     = T.CDH.circumcenter
     C.BD    = circle : new (z.B,z.D)
     L.FD    = line: new (z.F,z.D)
     z.G     = intersection (L.FD,C.BD)
     z.O     = intersection (L.EC,L.FD)
  }
  \begin{center}
    \begin{tikzpicture}[scale = .5]
    \tkzGetNodes
    \tkzDrawCircles(A,E B,H)
    \tkzDrawSegments(E,D C,F)
    \tkzDrawLines(E,O F,O)
    \tkzDrawLines[red](E,F H,G)
    \tkzDrawPoints(A,...,H,O)
    \tkzLabelPoints(A,B,D,F,G,O)
    \tkzLabelPoints[above](E,C,H)
    \tkzMarkAngles[size=.5](E,C,F E,D,F)
    \tkzFillAngles[green!40,opacity=.4,size=.5](E,C,F E,D,F)
    \tkzMarkAngles[size=.5](F,C,H G,D,E)
    \tkzFillAngles[red!40,opacity=.4,size=.5](F,C,H G,D,E)
    \end{tikzpicture}
  \end{center}
\end{minipage}



% subsection reim_v1 (end)

\subsection{Reim v2} % (fold)
\label{sub:reim_v2}

\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
 z.A      = point: new (0,0)
 z.B      = point: new (10,0)
 z.C      = point: new (4,0)
 C.AC     = circle: new (z.A,z.C)
 z.c,z.cp = get_points (C.AC: tangent_at (z.C))
 z.M      = C.AC: point (0.6)
 L.MC     = line: new (z.M,z.C)
 C.BC     = circle: new (z.B,z.C)
 z.N      = intersection (L.MC,C.BC)
 z.m,z.mp = get_points (C.AC: tangent_at (z.M))
 z.n,z.np = get_points (C.BC: tangent_at (z.N))
}
  \end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
  \directlua{%
  init_elements ()
  z.A     = point: new (0,0)
  z.B     = point: new (10,0)
  z.C     = point: new (4,0)
  C.AC    = circle: new (z.A,z.C)
  z.c,z.cp    = get_points (C.AC: tangent_at (z.C))
  z.M      = C.AC: point (0.6)
  L.MC    = line: new (z.M,z.C)
  C.BC    = circle: new (z.B,z.C)
  z.N     = intersection (L.MC,C.BC)
  z.m,z.mp    = get_points (C.AC: tangent_at (z.M))
  z.n,z.np    = get_points (C.BC: tangent_at (z.N))
  }
  
\begin{center}
  \begin{tikzpicture}[scale = .25]
  \tkzGetNodes
  \tkzDrawCircles(A,C B,C)
  \tkzDrawLines[new,add=1 and 1](M,m N,n C,c)
  \tkzDrawSegment(M,N)
  \tkzDrawPoints(A,B,C,M,N)
  \tkzLabelPoints[below right](A,B,C,M,N)
  \tkzFillAngles[blue!30,opacity=.3](m',M,C N,C,c' M,C,c n',N,C)
  \tkzLabelCircle[below=4pt,font=\scriptsize](A,C)(90){$(\alpha)$}
  \tkzLabelCircle[left=4pt,font=\scriptsize](B,C)(-90){$(\beta)$}
  \end{tikzpicture}
\end{center}
\end{minipage}

\begin{Verbatim}
  \begin{tikzpicture}[scale = .25]
     \tkzGetNodes
     \tkzDrawCircles(A,C B,C)
     \tkzDrawLines[new,add=1 and 1](M,m N,n C,c)
     \tkzDrawSegment(M,N)
     \tkzDrawPoints(A,B,C,M,N)
     \tkzLabelPoints[below right](A,B,C,M,N)
     \tkzFillAngles[blue!30,opacity=.3](m',M,C N,C,c' M,C,c n',N,C)
     \tkzLabelCircle[below=4pt,font=\scriptsize](A,C)(90){$(\alpha)$}
     \tkzLabelCircle[left=4pt,font=\scriptsize](B,C)(-90){$(\beta)$}
  \end{tikzpicture}
\end{Verbatim}

% subsection reim_v2 (end)

\subsection{Reim v3} % (fold)
\label{sub:reim_v3}

\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
   z.A     = point: new (0,0)
   z.B     = point: new (8,0)
   z.C     = point: new (2,6)
   L.AB    = line : new (z.A,z.B)
   L.AC    = line : new (z.A,z.C)
   L.BC    = line : new (z.B,z.C)
   z.I     = L.BC : point (0.75)
   z.J     = L.AC : point (0.4)
   z.K     = L.AB : point (0.5)
   T.AKJ   = triangle : new (z.A,z.K,z.J)
   T.BIK   = triangle : new (z.B,z.I,z.K)
   T.CIJ   = triangle : new (z.C,z.I,z.J)
   z.x     = T.AKJ.circumcenter
   z.y     = T.BIK.circumcenter
   z.z     = T.CIJ.circumcenter
   C.xK    = circle: new (z.x,z.K)
   C.yK    = circle: new (z.y,z.K)
   z.O,_   = intersection (C.xK,C.yK)
   C.zO    = circle: new (z.z,z.O)
   L.KO    = line: new (z.K,z.O)
   z.D     = intersection (L.KO,C.zO)
}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawSegments(K,D D,C)
   \tkzDrawPolygon[teal](A,B,C)
   \tkzDrawCircles[orange](x,A y,B z,C)
   \tkzDrawPoints[fill=white](A,B,C,I,J,K,D)
   \tkzLabelPoints[below](A,B,J,K,O)
   \tkzLabelPoints[above](C,D,I)
   \tkzDrawPoints[fill=black](O)
   \tkzLabelCircle[below=4pt,font=\scriptsize](x,A)(20){$(\alpha)$}
   \tkzLabelCircle[left=4pt,font=\scriptsize](y,B)(60){$(\beta)$}
   \tkzLabelCircle[below=4pt,font=\scriptsize](z,C)(60){$(\gamma)$}
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
  \directlua{%
  init_elements ()
     z.A     = point: new (0,0)
     z.B     = point: new (8,0)
     z.C     = point: new (2,6)
     L.AB    = line : new (z.A,z.B)
     L.AC    = line : new (z.A,z.C)
     L.BC    = line : new (z.B,z.C)
     z.I     = L.BC : point (0.75)
     z.J     = L.AC : point (0.4)
     z.K     = L.AB : point (0.5)
     T.AKJ   = triangle : new (z.A,z.K,z.J)
     T.BIK   = triangle : new (z.B,z.I,z.K)
     T.CIJ   = triangle : new (z.C,z.I,z.J)
     z.x     = T.AKJ.circumcenter
     z.y     = T.BIK.circumcenter
     z.z     = T.CIJ.circumcenter
     C.xK    = circle: new (z.x,z.K)
     C.yK    = circle: new (z.y,z.K)
     z.O,_   = intersection (C.xK,C.yK)
     C.zO    = circle: new (z.z,z.O)
     L.KO    = line: new (z.K,z.O)
     z.D     = intersection (L.KO,C.zO)
  }
  \begin{center}
    \begin{tikzpicture}[scale = .75]
    \tkzGetNodes
    \tkzDrawSegments(K,D D,C)
    \tkzDrawPolygon[teal](A,B,C)
    \tkzDrawCircles[orange](x,A y,B z,C)
    \tkzDrawPoints[fill=white](A,B,C,I,J,K,D)
    \tkzLabelPoints[below](A,B,J,K,O)
    \tkzLabelPoints[above](C,D,I)
    \tkzDrawPoints[fill=black](O)
    \tkzLabelCircle[below=4pt,font=\scriptsize](x,A)(20){$(\alpha)$}
    \tkzLabelCircle[left=4pt,font=\scriptsize](y,B)(60){$(\beta)$}
    \tkzLabelCircle[below=4pt,font=\scriptsize](z,C)(60){$(\gamma)$}
    \end{tikzpicture}
  \end{center}
\end{minipage}

% subsection reim_v3 (end)

\subsection{Tangent and circle} % (fold)
\label{sub:tangent_and_circle}
\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
   z.A         = point:    new (1,0)
   z.B         = point:    new (2,2)
   z.E         = point:    new (5,-4)
   L.AE        = line :    new (z.A,z.E)
   C.AB        = circle:   new (z.A , z.B)
   z.S         = C.AB.south
   z.M         = L.AE.mid
   L.Ti,L.Tj   = C.AB:   tangent_from (z.E)
   z.i         = L.Ti.pb
   z.j         = L.Tj.pb
   z.k,z.l     = get_points (C.AB:  tangent_at (z.B))
}
\begin{tikzpicture}[scale = .75]
   \tkzGetNodes
   \tkzDrawCircles(A,B M,A)
   \tkzDrawPoints(A,B,E,i,j,M,S)
   \tkzDrawLines(E,i E,j k,l)
   \tkzLabelPoints[right,font=\small](A,B,E,S,M)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{%
init_elements ()
z.A     = point:    new (1,0)
z.B     = point:    new (2,2)
z.E     = point:    new (5,-4)
L.AE    = line :    new (z.A,z.E)
C.AB    = circle:   new (z.A , z.B)
z.S     = C.AB.south
z.M     = L.AE.mid
L.Ti,L.Tj   = C.AB:   tangent_from (z.E)
z.i     = L.Ti.pb
z.j     = L.Tj.pb
z.k,z.l = get_points (C.AB:  tangent_at (z.B))
}

\begin{center}
  \begin{tikzpicture}[scale = .75]
  \tkzGetNodes
  \tkzDrawCircles(A,B M,A)
  \tkzDrawPoints(A,B,E,i,j,M,S)
  \tkzDrawLines(E,i E,j k,l)
  \tkzLabelPoints[right,font=\small](A,B,E,S,M)
  \end{tikzpicture}
\end{center}

\end{minipage}
% subsection tangent_and_circle (end)

\subsection{Homothety} % (fold)
\label{sub:homothety}
\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
   z.A      = point:  new (0,0)
   z.B      = point:  new (1,2)
   z.E      = point:  new (-3,2)
   z.C,z.D  = z.E : homothety(2,z.A,z.B)
}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPoints(A,B,C,E,D)
   \tkzLabelPoints(A,B,C,E)
   \tkzDrawCircles(A,B C,D)
   \tkzDrawLines(E,C E,D)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{%
init_elements ()
z.A  = point:  new (0,0)
z.B  = point:  new (1,2)
z.E  = point:  new (-3,2)
z.C,z.D  = z.E : homothety(2,z.A,z.B)
}
\begin{center}
  \begin{tikzpicture}[scale = .5]
  \tkzGetNodes
  \tkzDrawPoints(A,B,C,E,D)
  \tkzLabelPoints(A,B,C,E)
  \tkzDrawCircles(A,B C,D)
  \tkzDrawLines(E,C E,D)
  \end{tikzpicture}
\end{center}

\end{minipage}
% subsection homothety (end)

\subsection{Tangent and chord} % (fold)
\label{sub:tangent_and_chord}
\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
 z.A       = point: new (0 , 0)
 z.B       = point: new (6 , 0)
 z.C       = point: new (1 , 5)
 z.Bp      = point: new (2 , 0)
 T.ABC     = triangle: new (z.A,z.B,z.C)
 L.AB      = line: new (z.A,z.B)
 z.O       = T.ABC.circumcenter
 C.OA      = circle: new (z.O,z.A)
 z.D       = C.OA: point (4.5)
 L.AO      = line: new (z.A,z.O)
 z.b1,z.b2 = get_points(C.OA: tangent_at(z.B))
 z.H       = L.AB: projection (z.O)
}
\begin{tikzpicture}[scale   = 0.75]
   \tkzGetNodes
   \tkzDrawCircle(O,A)
   \tkzDrawPolygon(A,B,C)
   \tkzDrawSegments[new](A,O B,O O,H A,D D,B)
   \tkzDrawLine(b1,b2)
   \tkzDrawPoints(A,B,C,D,H,O)
   \tkzFillAngles[green!20,opacity=.3](H,O,B A,C,B  A,B,b1)
   \tkzFillAngles[teal!20,opacity=.3](A,D,B b2,B,A)
   \tkzLabelPoints(A,B,C,D,H,O)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{%
init_elements ()
z.A     = point: new (0 , 0)
z.B     = point: new (6 , 0)
z.C     = point: new (1 , 5)
z.Bp    = point: new (2 , 0)
T.ABC   = triangle: new (z.A,z.B,z.C)
L.AB    = line: new (z.A,z.B)
z.O     = T.ABC.circumcenter
C.OA    = circle: new (z.O,z.A)
z.D     = C.OA: point (4.5)
L.AO    = line: new (z.A,z.O)
z.b1,z.b2  = get_points (C.OA: tangent_at (z.B))
z.H     = L.AB: projection (z.O)
}
\begin{center}
  \begin{tikzpicture}[scale   = 0.75]
  \tkzGetNodes
  \tkzDrawCircle(O,A)
  \tkzDrawPolygon(A,B,C)
  \tkzDrawSegments[new](A,O B,O O,H A,D D,B)
  \tkzDrawSegment(b1,b2)
  \tkzDrawPoints(A,B,C,D,H,O)
  \tkzFillAngles[green!20,opacity=.3](H,O,B A,C,B  A,B,b1)
  \tkzFillAngles[teal!20,opacity=.3](A,D,B b2,B,A)
  \tkzLabelPoints(A,B,C,D,H,O)
  \end{tikzpicture}
\end{center}

\end{minipage}
% subsection tangent_and_chord (end)


\subsection{Three chords} % (fold)
\label{sub:three_chords}

\directlua{%
init_elements ()
z.O  = point: new (0 , 0)
z.B  = point: new (0 , 2)
z.P  = point: new (1 , -.5)
C.OB = circle : new (z.O,z.B)
C.PB = circle : new (z.P,z.B)
_,z.A    = intersection (C.OB,C.PB)
z.D  = C.PB: point(0.85)
z.C  = C.PB: point(0.5)
z.E  = C.OB: point(0.6)
L.AB = line : new (z.A,z.B)
L.CD = line : new (z.C,z.D)
z.G  = intersection (L.AB,L.CD)
L.GE = line : new (z.G,z.E)
z.F,_    = intersection (L.GE,C.OB)
T.CDE    = triangle: new (z.C,z.D,z.E)
T.BFD    = triangle: new (z.B,z.F,z.D)
z.w  = T.CDE.circumcenter
z.x  = T.BFD.circumcenter
L.GB = line : new (z.G,z.B)
L.GE = line : new (z.G,z.E)
L.GD = line : new (z.G,z.D)
C.xB = circle : new (z.x,z.B)
C.xF = circle : new (z.x,z.F)
C.xD = circle : new (z.x,z.D)
z.Ap = intersection (L.GB,C.xB)
z.Ep,_   = intersection (L.GE,C.xF)
z.Cp,_   = intersection (L.GD,C.xD)
}

\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
z.O  = point: new (0 , 0)
z.B  = point: new (0 , 2)
z.P  = point: new (1 , -.5)
C.OB = circle : new (z.O,z.B)
C.PB = circle : new (z.P,z.B)
_,z.A    = intersection (C.OB,C.PB)
z.D  = C.PB: point(0.85)
z.C  = C.PB: point(0.5)
z.E  = C.OB: point(0.6)
L.AB = line : new (z.A,z.B)
L.CD = line : new (z.C,z.D)
z.G  = intersection (L.AB,L.CD)
L.GE = line : new (z.G,z.E)
z.F,_    = intersection (L.GE,C.OB)
T.CDE    = triangle: new (z.C,z.D,z.E)
T.BFD    = triangle: new (z.B,z.F,z.D)
z.w  = T.CDE.circumcenter
z.x  = T.BFD.circumcenter
L.GB = line : new (z.G,z.B)
L.GE = line : new (z.G,z.E)
L.GD = line : new (z.G,z.D)
C.xB = circle : new (z.x,z.B)
C.xF = circle : new (z.x,z.F)
C.xD = circle : new (z.x,z.D)
z.Ap = intersection (L.GB,C.xB)
z.Ep,_   = intersection (L.GE,C.xF)
z.Cp,_   = intersection (L.GD,C.xD)
}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\begin{center}
  \begin{tikzpicture}[scale=.75]
  \tkzGetNodes
  \tkzDrawCircles(O,B)
  \tkzDrawCircles[cyan](P,B)
  \tkzDrawCircles[red](w,E)
  \tkzDrawCircles[new](x,F)
  \tkzDrawSegments(A,G E,G C,G)
  \tkzDrawPolygons[new](A,E,C A',E',C')
  \tkzDrawPoints(A,...,G,A',E',C',O,P)
  \begin{scope}[font=\scriptsize]
     \tkzLabelPoints(A,...,F)
     \tkzLabelPoints[above left](G,A',E',C')
     \tkzLabelCircle[left](O,B)(30){$(\beta)$}
     \tkzLabelCircle[below](P,A)(40){$(\gamma)$}
     \tkzLabelCircle[right](w,C)(90){$(\alpha)$}
     \tkzLabelCircle[left](x,B)(-230){$((\delta))$}
  \end{scope}
  \end{tikzpicture}
\end{center}
\end{minipage}

\begin{Verbatim}
\begin{tikzpicture}
  \tkzGetNodes
  \tkzDrawCircles(O,B)
  \tkzDrawCircles[cyan](P,B)
  \tkzDrawCircles[red](w,E)
  \tkzDrawCircles[new](x,F)
  \tkzDrawSegments(A,G E,G C,G)
  \tkzDrawPolygons[new](A,E,C A',E',C')
  \tkzDrawPoints(A,...,G,A',E',C',O,P)
  \begin{scope}[font=\scriptsize]
  \tkzLabelPoints(A,...,F)
  \tkzLabelPoints[above left](G,A',E',C')
  \tkzLabelCircle[left](O,B)(30){$(\beta)$}
  \tkzLabelCircle[below](P,A)(40){$(\gamma)$}
  \tkzLabelCircle[right](w,C)(90){$(\alpha)$}
  \tkzLabelCircle[left](x,B)(-230){$((\delta))$}
  \end{scope}
\end{tikzpicture}
\end{Verbatim}

% subsection three_chords (end)

\subsection{Three tangents} % (fold)
\label{sub:three_tangents}

\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\begin{Verbatim}
\directlua{%
init_elements ()
   z.A    = point: new (-1 , 0)
   z.C    = point: new (4 , -1.5)
   z.E    = point: new (1 , -1)
   z.F    = point: new (1.5 , 2.5)
   T.AEF  = triangle : new (z.A,z.E,z.F)
   T.CEF  = triangle : new (z.C,z.E,z.F)
   z.w    = T.AEF.circumcenter
   z.x    = T.CEF.circumcenter
   C.wE   = circle : new (z.w,z.E)
   C.xE   = circle : new (z.x,z.E)
   L.Aw   = line : new (z.A,z.w)
   L.Cx   = line : new (z.C,z.x)
   z.G    = intersection (L.Aw,L.Cx)
   L.TA   = C.wE : tangent_at (z.A)
   L.TC   = C.xE : tangent_at (z.C)
   z.I    = intersection (L.TA,L.TC)
}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawCircles(w,E)
   \tkzDrawCircles[cyan](x,E)
   \tkzDrawCircles[red](G,A)
   \tkzDrawLines(A,I C,I F,I)
   \tkzDrawPoints(A,C,E,F)
   \tkzLabelPoints[right](A)
   \tkzLabelPoints[above right](E,F)
   \tkzLabelPoints[below](C)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\directlua{%
init_elements ()
z.A    = point: new (-1 , 0)
z.C    = point: new (4 , -1.5)
z.E    = point: new (1 , -1)
z.F    = point: new (1.5 , 2.5)
T.AEF  = triangle : new (z.A,z.E,z.F)
T.CEF  = triangle : new (z.C,z.E,z.F)
z.w    = T.AEF.circumcenter
z.x    = T.CEF.circumcenter
C.wE   = circle : new (z.w,z.E)
C.xE   = circle : new (z.x,z.E)
L.Aw   = line : new (z.A,z.w)
L.Cx   = line : new (z.C,z.x)
z.G    = intersection (L.Aw,L.Cx)
L.TA   = C.wE : tangent_at (z.A)
L.TC   = C.xE : tangent_at (z.C)
z.I    = intersection (L.TA,L.TC)
}

\begin{center}
  \begin{tikzpicture}[scale=.75]
  \tkzGetNodes
  \tkzDrawCircles(w,E)
  \tkzDrawCircles[cyan](x,E)
  \tkzDrawCircles[red](G,A)
  \tkzDrawLines(A,I C,I F,I)
  \tkzDrawPoints(A,C,E,F)
  \tkzLabelPoints[right](A)
  \tkzLabelPoints[above right](E,F)
  \tkzLabelPoints[below](C)
  \end{tikzpicture}
\end{center}
\end{minipage}
% subsection three_tangents (end)

\subsection{Midarc} % (fold)
\label{sub:midarc}
\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\begin{Verbatim}
\directlua{%
init_elements ()
   z.A   = point:  new (-1,0)
   z.B   = point:  new (2,4)
   C.AB  = circle: new (z.A,z.B)
   z.C   =  z.A: rotation (math.pi/3,z.B)
   z.D   = C.AB: midarc (z.B,z.C)
}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPoints(A,B,C)
   \tkzDrawCircles(A,B)
   \tkzDrawPoints(A,...,D)
   \tkzLabelPoints(A,...,D)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\directlua{%
init_elements ()
z.A  = point:  new (-1,0)
z.B  = point:  new (2,4)
C.AB = circle:  new (z.A,z.B)
z.C =  z.A: rotation (math.pi/3,z.B)
z.D = C.AB: midarc (z.B,z.C)
}

\begin{center}
  \begin{tikzpicture}[scale = .5]
  \tkzGetNodes
  \tkzDrawPoints(A,B,C)
  \tkzDrawCircles(A,B)
  \tkzDrawPoints(A,...,D)
  \tkzLabelPoints(A,...,D)
  \end{tikzpicture}
\end{center}
\end{minipage}
% subsection midarc (end)

\subsection{Lemoine axis without macro} % (fold)
\label{sub:lemoine_line_without_macro}

\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\begin{Verbatim}
\directlua{%
init_elements ()
   z.A         = point: new (1,0)
   z.B         = point: new (5,2)
   z.C         = point: new (1.2,2)
   T           = triangle: new(z.A,z.B,z.C)
   z.O         = T.circumcenter
   L.AB        = line: new (z.A,z.B)
   L.AC        = line: new (z.A,z.C)
   L.BC        = line: new (z.B,z.C)
   C.OA        = circle: new (z.O,z.A)
   z.Ar,z.Al   = get_points (C.OA: tangent_at (z.A))
   z.Br,z.Bl   = get_points (C.OA: tangent_at (z.B))
   z.Cr,z.Cl   = get_points (C.OA: tangent_at (z.C))
   L.tA        = line: new (z.Ar,z.Al)
   L.tB        = line: new (z.Br,z.Bl)
   L.tC        = line: new (z.Cr,z.Cl)
   z.P         = intersection (L.tA,L.BC)
   z.Q         = intersection (L.tB,L.AC)
   z.R         = intersection (L.tC,L.AB)
}
\begin{tikzpicture}[scale= 1.6]
   \tkzGetNodes
   \tkzDrawPolygon[teal](A,B,C)
   \tkzDrawCircle(O,A)
   \tkzDrawPoints(A,B,C,P,Q,R)
   \tkzLabelPoints(A,B,C,P,Q,R)
   \tkzDrawLine[blue](Q,R)
   \tkzDrawLines[red](Ar,Al Br,Q Cr,Cl)
   \tkzDrawSegments(A,R C,P C,Q)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}[t]{.5\textwidth}\vspace{0pt}%
\directlua{%
init_elements ()
z.A         = point: new (1,0)
z.B         = point: new (5,2)
z.C         = point: new (1.2,2)
T           = triangle: new(z.A,z.B,z.C)
z.O         = T.circumcenter
L.AB        = line: new (z.A,z.B)
L.AC        = line: new (z.A,z.C)
L.BC        = line: new (z.B,z.C)
C.OA        = circle: new (z.O,z.A)
z.Ar,z.Al   = get_points (C.OA: tangent_at (z.A))
z.Br,z.Bl   = get_points (C.OA: tangent_at (z.B))
z.Cr,z.Cl   = get_points (C.OA: tangent_at (z.C))
L.tA        = line: new (z.Ar,z.Al)
L.tB        = line: new (z.Br,z.Bl)
L.tC        = line: new (z.Cr,z.Cl)
z.P         = intersection (L.tA,L.BC)
z.Q         = intersection (L.tB,L.AC)
z.R         = intersection (L.tC,L.AB)
}

\begin{center}
  \begin{tikzpicture}[scale = 0.75]
  \tkzGetNodes
  \tkzDrawPolygon[teal](A,B,C)
  \tkzDrawCircle(O,A)
  \tkzDrawPoints(A,B,C,P,Q,R)
  \tkzLabelPoints(A,B,C,P,Q,R)
  \tkzDrawLine[blue](Q,R)
  \tkzDrawLines[red](Ar,Al Br,Q Cr,Cl)
  \tkzDrawSegments(A,R C,P C,Q)
  \end{tikzpicture}
\end{center}

\end{minipage}
% subsection lemoine_line_without_macro (end)

\subsection{First Lemoine circle} % (fold)
\label{sub:first_lemoine_circle}

Draw lines through the symmedian point $L$ and parallel to the sides of the triangle. The points where the parallel lines intersect the sides of the triangle then lie on a circle known as the first Lemoine circle.  It has center at the Brocard midpoint, i.e., the midpoint of $[OL]$, where $O$ is the circumcenter and $K$ is the symmedian point

[\href{https://mathworld.wolfram.com/FirstLemoineCircle.html}{Weisstein, Eric W. "First Lemoine Circle." From MathWorld--A Wolfram Web Resource.}]

\vspace{6pt}
\begin{minipage}[t]{.35\textwidth}\vspace{0pt}%
\directlua{%
init_elements ()
   z.A      = point:  new (1,1)
   z.B      = point:  new (5,1)
   z.C      = point:  new (2.2,4)
   T        = triangle: new (z.A,z.B,z.C) 
   z.O = T.circumcenter
   C.first_lemoine = T:first_lemoine_circle()
  z.o,z.w  = get_points( C.first_lemoine )
   z.y1,z.y2         = intersection (T.ab,C.first_lemoine)
   z.y5,z.y6         = intersection (T.bc,C.first_lemoine)
   z.y3,z.y4         = intersection (T.ca,C.first_lemoine)
   z.L      = T : lemoine_point ()
}

\begin{center}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPolygons(A,B,C)
   \tkzDrawPoints(A,B,C,o,O,L,y1,y2,y3,y4,y5,y6)
   \tkzLabelPoints(A,B,C,o,O,L,y1,y2,y3,y4,y5,y6)
   \tkzDrawCircles(o,w)
   \tkzDrawLines(y1,y6 y5,y4 y2,y3 O,L)  
\end{tikzpicture}
\end{center}
\end{minipage}
\begin{minipage}[t]{.65\textwidth}\vspace{0pt}%
\begin{Verbatim}
\directlua{%
init_elements ()
 z.A  = point:  new (1,1)
 z.B  = point:  new (5,1)
 z.C  = point:  new (2.2,4)
 T    = triangle:new(z.A,z.B,z.C) 
 z.O  = T.circumcenter
 C.first_lemoine = T:first_lemoine_circle()
 z.o,z.w  = get_points( C.first_lemoine )
 z.y1,z.y2= intersection (T.ab,C.first_lemoine)
 z.y5,z.y6= intersection (T.bc,C.first_lemoine)
 z.y3,z.y4= intersection (T.ca,C.first_lemoine)
 z.L      = T:lemoine_point ()
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPolygons(A,B,C)
   \tkzDrawPoints(A,B,C,o,O,L,y1,y2,y3,y4,y5,y6)
   \tkzLabelPoints(A,B,C,o,O,L,y1,y2,y3,y4,y5,y6)
   \tkzDrawCircles(o,w)
   \tkzDrawLines(y1,y6 y5,y4 y2,y3 O,L)  
\end{tikzpicture}
\end{Verbatim}
\end{minipage}

% subsection first_lemoine_circle (end)

\subsection{First and second Lemoine circles} % (fold)
\label{sub:first_and_second_lemoine_circles}

Draw antiparallels through the symmedian point $L$. The points where these lines intersect the sides then lie on a circle, known as the cosine circle (or sometimes the second Lemoine circle). Refer to [\ref{sub:antiparallel_through_lemoine_point}]

[\href{https://mathworld.wolfram.com/CosineCircle.html}{Weisstein, Eric W. "Cosine Circle." From MathWorld--A Wolfram Web Resource.}]


\begin{Verbatim}
\directlua{%
init_elements ()
 z.a             = point:  new (0,0)
 z.b             = point:  new (5,0)
 z.c             = point:  new (2,3)
 T               = triangle: new (z.a,z.b,z.c)
 z.O             = T.circumcenter
 z.o,z.p         = get_points (T : first_lemoine_circle ())
 L.ab            = line : new (z.a,z.b)
 L.ca            = line : new (z.c,z.a)
 L.bc            = line : new (z.b,z.c)
 z.L,z.x         = get_points (T : second_lemoine_circle ())
 C.first_lemoine = circle : new (z.o,z.p)
 z.y1,z.y2       = intersection (L.ab,C.first_lemoine)
 z.y5,z.y6       = intersection (L.bc,C.first_lemoine)
 z.y3,z.y4       = intersection (L.ca,C.first_lemoine)
 C.second_lemoine= circle : new (z.L,z.x)
 z.x1,z.x2       = intersection (L.ab,C.second_lemoine)
 z.x3,z.x4       = intersection (L.bc,C.second_lemoine)
 z.x5,z.x6       = intersection (L.ca,C.second_lemoine)
 L.y1y6          = line : new (z.y1,z.y6)
 L.y4y5          = line : new (z.y4,z.y5)
 L.y2y3          = line : new (z.y2,z.y3)
}
\begin{tikzpicture}[scale = 1.5]
   \tkzGetNodes
   \tkzDrawPolygons(a,b,c y1,y2,y3,y4,y5,y6)
   \tkzDrawPoints(x1,x2,x3,x4,x5,x6,L)
   \tkzDrawPoints(a,b,c,o,O,y1,y2,y3,y4,y5,y6)
   \tkzLabelPoints[below right](a,b,c,o,O,y1,y2,y3,y4,y5,y6)
   \tkzLabelPoints[below left](x1,x2,x3,x4,x5,x6)
   \tkzLabelPoints[above](L)
   \tkzDrawCircles(L,x o,p O,a)
   \tkzDrawSegments(L,O x1,x4 x2,x5 x3,x6)
\end{tikzpicture}
\end{Verbatim}

\directlua{%
init_elements ()
z.a   = point:  new (0,0)
z.b   = point:  new (5,0)
z.c   = point:  new (2,3)
T     = triangle: new (z.a,z.b,z.c)
z.O   = T.circumcenter
z.o,z.p   = get_points (T : first_lemoine_circle ())
L.ab      = line : new (z.a,z.b)
L.ca      = line : new (z.c,z.a)
L.bc      = line : new (z.b,z.c)
z.L,z.x   = get_points (T : second_lemoine_circle ())
C.first_lemoine   = circle : new (z.o,z.p)
z.y1,z.y2     = intersection (L.ab,C.first_lemoine)
z.y5,z.y6     = intersection (L.bc,C.first_lemoine)
z.y3,z.y4     = intersection (L.ca,C.first_lemoine)
C.second_lemoine  = circle : new (z.L,z.x)
z.x1,z.x2     = intersection (L.ab,C.second_lemoine)
z.x3,z.x4     = intersection (L.bc,C.second_lemoine)
z.x5,z.x6     = intersection (L.ca,C.second_lemoine)
L.y1y6    = line : new (z.y1,z.y6)
L.y4y5    = line : new (z.y4,z.y5)
L.y2y3    = line : new (z.y2,z.y3)
}

\begin{center}
  \begin{tikzpicture}[scale = 1.5]
  \tkzGetNodes
  \tkzDrawPolygons(a,b,c y1,y2,y3,y4,y5,y6)
  \tkzDrawPoints(x1,x2,x3,x4,x5,x6,L)
  \tkzDrawPoints(a,b,c,o,O,y1,y2,y3,y4,y5,y6)
  \tkzLabelPoints[below right](a,b,c,o,O,y1,y2,y3,y4,y5,y6)
  \tkzLabelPoints[below left](x1,x2,x3,x4,x5,x6)
  \tkzLabelPoints[above](L)
  \tkzDrawCircles(L,x o,p O,a)
  \tkzDrawSegments(L,O x1,x4 x2,x5 x3,x6)
  \end{tikzpicture}
\end{center}


% subsection first_and_second_lemoine_circles (end)

\subsection{Inversion} % (fold)
\label{sub:inversion}

\directlua{%
init_elements ()
z.A     = point: new (-1,0)
z.B     = point: new (2,2)
z.C     = point: new (2,4)
z.E     = point: new (1,6)
C.AC    = circle:    new (z.A,z.C)
L.Tt1,L.Tt2 = C.AC: tangent_from (z.E)
z.t1    = L.Tt1.pb
z.t2    = L.Tt2.pb
L.AE    = line: new (z.A,z.E)
z.H     = L.AE : projection (z.t1)
z.Bp,
z.Ep,
z.Cp    = C.AC: inversion ( z.B, z.E, z.C )
}


\begin{minipage}{.5\textwidth}
\begin{Verbatim}
 \directlua{%
init_elements ()
  z.A     = point: new (-1,0)
  z.B     = point: new (2,2)
  z.C     = point: new (2,4)
  z.E     = point: new (1,6)
  C.AC    = circle:    new (z.A,z.C)
  L.Tt1,
  L.Tt2   = C.AC: tangent_from (z.E)
  z.t1    = L.Tt1.pb
  z.t2    = L.Tt2.pb
  L.AE    = line: new (z.A,z.E)
  z.H     = L.AE : projection (z.t1)
  z.Bp,
  z.Ep,
  z.Cp    = C.AC: inversion ( z.B, z.E, z.C )
}

\begin{tikzpicture}[scale = .5]
  \tkzGetNodes
  \tkzDrawPoints(A,B,C)
  \tkzDrawCircles(A,C A,B)
  \tkzDrawLines(A,B' E,t1 E,t2 t1,t2 A,E)
  \tkzDrawPoints(A,B,C,E,t1,t2,H,B',E')
  \tkzLabelPoints(A,B,C,E,t1,t2,B',E')
  \tkzLabelPoints[above](C')
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
 \begin{tikzpicture}[scale=.6]
   \tkzGetNodes
   \tkzDrawPoints(A,B,C)
   \tkzDrawCircles(A,C A,B)
   \tkzDrawLines(A,B' E,t1 E,t2 t1,t2 A,E)
   \tkzDrawPoints(A,B,C,E,t1,t2,H,B',E')
   \tkzLabelPoints(A,B,C,E,t1,t2,B',E')
   \tkzLabelPoints[above](C')
 \end{tikzpicture} 
\end{minipage}
% subsection inversion (end)


\subsection{Antiparallel through Lemoine point} % (fold)
\label{sub:antiparallel_through_lemoine_point}


\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
   z.a         = point:  new (0,0)
   z.b         = point:  new (5,0)
   z.c         = point:  new (1,4)
   T           = triangle: new (z.a,z.b,z.c)
   z.L         = T : lemoine_point ()
   L.anti      = T : antiparallel (z.L,0)
   z.x_0,z.x_1 = get_points (L.anti)
   L.anti      = T : antiparallel (z.L,1)
   z.y_0,z.y_1 = get_points (L.anti)
   L.anti      = T : antiparallel (z.L,2)
   z.z_0,z.z_1 = get_points (L.anti)
}

\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPolygons(a,b,c)
   \tkzDrawPoints(a,b,c,L,x_0,x_1,y_0,y_1,z_0,z_1)
   \tkzLabelPoints(a,b)
   \tkzLabelPoints[above](L,c)
   \tkzDrawSegments(x_0,x_1 y_0,y_1 z_0,z_1)
   \tkzDrawCircle(L,x_0)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{%
init_elements ()
z.a = point:  new (0,0)
z.b = point:  new (5,0)
z.c = point:  new (1,4)
T = triangle: new (z.a,z.b,z.c)
z.L = T : lemoine_point ()
L.anti = T : antiparallel (z.L,0)
z.x_0,z.x_1 = get_points (L.anti)
L.anti = T : antiparallel (z.L,1)
z.y_0,z.y_1 = get_points (L.anti)
L.anti = T : antiparallel (z.L,2)
z.z_0,z.z_1 = get_points (L.anti)
}

\begin{center}
  \begin{tikzpicture}
  \tkzGetNodes
  \tkzDrawPolygons(a,b,c)
  \tkzDrawPoints(a,b,c,L,x_0,x_1,y_0,y_1,z_0,z_1)
  \tkzLabelPoints(a,b)
  \tkzLabelPoints[above](L,c)
  \tkzDrawSegments(x_0,x_1 y_0,y_1 z_0,z_1)
  \tkzDrawCircle(L,x_0)
  \end{tikzpicture}
\end{center}

\end{minipage}
% subsection antiparallel_through_lemoine_point (end)

\subsection{Pappus chain} % (fold)
\label{sub:pappus_chain}

\directlua{%
init_elements ()
  xC,nc    = 10,16
  xB       = xC/tkzphi
  xD       = (xC*xC)/xB
  xJ       = (xC+xD)/2
  r        = xD-xJ
  z.A      = point : new ( 0 , 0 )
  z.B      = point : new ( xB , 0)
  z.C      = point : new ( xC , 0)
  L.AC     = line : new (z.A,z.C)
  z.i      = L.AC.mid
  L.AB     = line:new (z.A,z.B)
  z.j      = L.AB.mid
  z.D      = point : new ( xD , 0)
  C.AC     = circle: new (z.A,z.C)
  for i    = -nc,nc do
     z["J"..i]   = point: new (xJ,2*r*i)
     z["H"..i]   = point: new (xJ,2*r*i-r)
     z["J"..i.."p"], z["H"..i.."p"]   = C.AC : inversion (z["J"..i],z["H"..i])
     L.AJ        = line : new (z.A,z["J"..i])
     C.JH        = circle: new ( z["J"..i] ,  z["H"..i])
     z["S"..i], z["T"..i]             = intersection (L.AJ,C.JH)
     z["S"..i.."p"], z["T"..i.."p"]   = C.AC : inversion (z["S"..i],z["T"..i])
     L.SpTp      = line:new (  z["S"..i.."p"], z["T"..i.."p"])
     z["I"..i]   = L.SpTp.mid
   end
}

\begin{Verbatim}
\directlua{%
init_elements ()
  xC,nc    = 10,16
  xB       = xC/tkzphi
  xD       = (xC*xC)/xB
  xJ       = (xC+xD)/2
  r        = xD-xJ
  z.A      = point : new ( 0 , 0 )
  z.B      = point : new ( xB , 0)
  z.C      = point : new ( xC , 0)
  L.AC     = line : new (z.A,z.C)
  z.i      = L.AC.mid
  L.AB     = line:new (z.A,z.B)
  z.j      = L.AB.mid
  z.D      = point : new ( xD , 0)
  C.AC     = circle: new (z.A,z.C)
  for i    = -nc,nc do
     z["J"..i]   = point: new (xJ,2*r*i)
     z["H"..i]   = point: new (xJ,2*r*i-r)
     z["J"..i.."p"], z["H"..i.."p"]   = C.AC : inversion (z["J"..i],z["H"..i])
     L.AJ        = line : new (z.A,z["J"..i])
     C.JH        = circle: new ( z["J"..i] ,  z["H"..i])
     z["S"..i], z["T"..i]             = intersection (L.AJ,C.JH)
     z["S"..i.."p"], z["T"..i.."p"]   = C.AC : inversion (z["S"..i],z["T"..i])
     L.SpTp      = line:new (  z["S"..i.."p"], z["T"..i.."p"])
     z["I"..i]   = L.SpTp.mid
   end
}
\end{Verbatim}

\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\def\nc{\tkzUseLua{nc}}
\begin{tikzpicture}[ultra thin]
   \tkzGetNodes
   \tkzDrawCircle[fill=teal!20](i,C)
   \tkzDrawCircle[fill=PineGreen!60](j,B)
   \foreach \i in {-\nc,...,0,...,\nc} {
   \tkzDrawCircle[fill=teal]({I\i},{S\i'})
  }
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
 \def\nc{\tkzUseLua{nc}}

 \begin{tikzpicture}[ultra thin,scale =.75]
    \tkzGetNodes
    \tkzDrawCircle[fill=teal!20](i,C)
    \tkzDrawCircle[fill=PineGreen!60](j,B)
    \foreach \i in {-\nc,...,0,...,\nc} {
    \tkzDrawCircle[fill=teal]({I\i},{S\i'})
   }
 \end{tikzpicture} 
 \vfill
\end{minipage}
% subsection pappus_chain (end)

\subsection{Three Circles} % (fold)
\label{sub:three_circles}

\directlua{%
init_elements ()
function threecircles(c1,r1,c2,r2,c3,h1,h3,h2)
   local xk = math.sqrt (r1*r2)
   local cx = (2*r1*math.sqrt(r2))/(math.sqrt(r1)+math.sqrt(r2))
   local cy = (r1*r2)/(math.sqrt(r1)+math.sqrt(r2))^2
   z[c2] = point : new ( 2*xk , r2 )
   z[h2] = point : new (2*xk,0)
   z[c1] = point : new (0,r1)
   z[h1] = point : new (0,0)
   L.h1h2 = line: new(z[h1],z[h2])
   z[c3] = point : new (cx,cy)
   z[h3] = L.h1h2: projection (z[c3])
end
   threecircles("A",4,"B",3,"C","E","G","F")
}

\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
function threecircles(c1,r1,c2,r2,c3,h1,h3,h2)
   local xk = math.sqrt (r1*r2)
   local cx = (2*r1*math.sqrt(r2))/(math.sqrt(r1)+math.sqrt(r2))
   local cy = (r1*r2)/(math.sqrt(r1)+math.sqrt(r2))^2
   z[c2] = point : new ( 2*xk , r2 )
   z[h2] = point : new (2*xk,0)
   z[c1] = point : new (0,r1)
   z[h1] = point : new (0,0)
   L.h1h2 = line: new(z[h1],z[h2])
   z[c3] = point : new (cx,cy)
   z[h3] = L.h1h2: projection (z[c3])
end
   threecircles("A",4,"B",3,"C","E","G","F")
}

\begin{tikzpicture}
  \tkzGetNodes
  \tkzDrawSegment[color = red](E,F)
  \tkzDrawCircle[orange,fill=orange!20](A,E)
  \tkzDrawCircle[purple,fill=purple!20](B,F)
  \tkzDrawCircle[teal,fill=teal!20](C,G)
\end{tikzpicture}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\begin{tikzpicture}[scale=.5]
\tkzGetNodes
\tkzDrawSegment[color = red](E,F)
\tkzDrawCircle[orange,fill=orange!20](A,E)
\tkzDrawCircle[purple,fill=purple!20](B,F)
\tkzDrawCircle[teal,fill=teal!20](C,G)
\end{tikzpicture}
\end{minipage}
% subsection three_circles (end)

\subsection{Pentagons in a golden arbelos} % (fold)
\label{sub:golden_arbelos}

\directlua{%
init_elements ()
z.A      = point: new (0 , 0)
z.B      = point: new (10 , 0)
L.AB     = line:  new ( z.A, z.B)
z.C      = L.AB : gold_ratio ()
L.AC     = line:  new ( z.A, z.C)
L.CB     = line:  new ( z.C, z.B)
z.O_0    = L.AB.mid
z.O_1    = L.AC.mid
z.O_2    = L.CB.mid
C.O0B    = circle: new ( z.O_0, z.B)
C.O1C    = circle: new ( z.O_1, z.C)
C.O2B    = circle: new ( z.O_2, z.B)
z.M_0    = C.O1C:external_similitude(C.O2B)
L.O0C    = line:new(z.O_0,z.C)
T.golden = L.O0C : golden ()
z.L      = T.golden.pc
L.O0L    = line:new(z.O_0,z.L)
z.D      = intersection (L.O0L,C.O0B)
L.DB     = line:new(z.D,z.B)
_,z.Z      = intersection (L.DB,C.O2B)
L.DA     = line:new(z.D,z.A)
z.I      = intersection (L.DA,C.O1C)
L.O2Z    = line:new(z.O_2,z.Z)
z.H      = intersection (L.O2Z,C.O0B)
C.BD     = circle:new (z.B,z.D)
C.DB     = circle:new (z.D,z.B)
_,z.G    = intersection (C.BD,C.O0B)
z.E      = intersection (C.DB,C.O0B)
C.GB     = circle:new (z.G,z.B)
_,z.F    = intersection (C.GB,C.O0B)
k        = 1/tkzphi^2
kk       = tkzphi
z.D_1,z.E_1,z.F_1,z.G_1 = z.B :   homothety (k, z.D,z.E,z.F,z.G)
z.D_2,z.E_2,z.F_2,z.G_2 = z.M_0 : homothety (kk,z.D_1,z.E_1,z.F_1,z.G_1)
}

\begin{minipage}{.5\textwidth}
\begin{Verbatim}
\directlua{%
init_elements ()
  z.A      = point: new (0 , 0)
  z.B      = point: new (10 , 0)
  L.AB     = line:  new ( z.A, z.B)
  z.C      = L.AB : gold_ratio ()
  L.AC     = line:  new ( z.A, z.C)
  L.CB     = line:  new ( z.C, z.B)
  z.O_0    = L.AB.mid
  z.O_1    = L.AC.mid
  z.O_2    = L.CB.mid
  C.O0B    = circle: new ( z.O_0, z.B)
  C.O1C    = circle: new ( z.O_1, z.C)
  C.O2B    = circle: new ( z.O_2, z.B)
  z.M_0    = C.O1C:external_similitude(C.O2B)
  L.O0C    = line:new(z.O_0,z.C)
  T.golden = L.O0C : golden ()
  z.L      = T.golden.pc
  L.O0L    = line:new(z.O_0,z.L)
  z.D      = intersection (L.O0L,C.O0B)
  L.DB     = line:new(z.D,z.B)
  z.Z      = intersection (L.DB,C.O2B)
  L.DA     = line:new(z.D,z.A)
  z.I      = intersection (L.DA,C.O1C)
  L.O2Z    = line:new(z.O_2,z.Z)
  z.H      = intersection (L.O2Z,C.O0B)
  C.BD     = circle:new (z.B,z.D)
  C.DB     = circle:new (z.D,z.B)
  _,z.G    = intersection (C.BD,C.O0B)
  z.E      = intersection (C.DB,C.O0B)
  C.GB     = circle:new (z.G,z.B)
  _,z.F    = intersection (C.GB,C.O0B)
  k        = 1/tkzphi^2
  kk       = tkzphi
  z.D_1,z.E_1,z.F_1,z.G_1 = z.B :   homothety (k, z.D,z.E,z.F,z.G)
  z.D_2,z.E_2,z.F_2,z.G_2 = z.M_0 : homothety (kk,z.D_1,z.E_1,z.F_1,z.G_1)
}
\end{Verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
  \hfill
\begin{tikzpicture}[scale=.7]
\tkzGetNodes
\tkzDrawPolygon[red](O_2,O_0,I,D,H)
\tkzDrawPolygon[blue](B,D_1,E_1,F_1,G_1)
\tkzDrawPolygon[green](C,D_2,E_2,F_2,G_2)
\tkzDrawPolygon[purple](B,D,E,F,G)
\tkzDrawCircles(O_0,B O_1,C O_2,B)
\tkzFillPolygon[fill=red!20,opacity=.20](O_2,O_0,I,D,H)
\tkzFillPolygon[fill=blue!20,opacity=.20](B,D_1,E_1,F_1,G_1)
\tkzFillPolygon[fill=green!60,opacity=.20](C,D_2,E_2,F_2,G_2)
\tkzFillPolygon[fill=purple!20,opacity=.20](B,D,E,F,G)
\tkzDrawCircles(O_0,B O_1,C O_2,B)
\tkzDrawSegments[new](A,B)
\tkzDrawPoints(A,B,C,O_0,O_1,O_2,Z,I,H,B,D,E,F)
\tkzDrawPoints(D_1,E_1,F_1,G_1)
\tkzDrawPoints(D_2,E_2,F_2,G_2)
\tkzDrawPoints[red](F_1)
\tkzLabelPoints(A,B,C,O_0,O_2)
\tkzLabelPoints[below](O_1,G)
\tkzLabelPoints[above right](D,H)
\tkzLabelPoints[above left](E,E_1,E_2)
\tkzLabelPoints[below left](F,F_1,F_2)
\tkzLabelPoints(D_1,G_1)
\tkzLabelPoints(D_2,G_2)
\end{tikzpicture}
\end{minipage}

\begin{Verbatim}
\begin{tikzpicture}[scale=.8]
\tkzGetNodes
\tkzDrawPolygon[red](O_2,O_0,I,D,H)
\tkzDrawPolygon[blue](B,D_1,E_1,F_1,G_1)
\tkzDrawPolygon[green](C,D_2,E_2,F_2,G_2)
\tkzDrawPolygon[purple](B,D,E,F,G)
\tkzDrawCircles(O_0,B O_1,C O_2,B)
\tkzFillPolygon[fill=red!20,opacity=.20](O_2,O_0,I,D,H)
\tkzFillPolygon[fill=blue!20,opacity=.20](B,D_1,E_1,F_1,G_1)
\tkzFillPolygon[fill=green!60,opacity=.20](C,D_2,E_2,F_2,G_2)
\tkzFillPolygon[fill=purple!20,opacity=.20](B,D,E,F,G)
\tkzDrawCircles(O_0,B O_1,C O_2,B)
\tkzDrawSegments[new](A,B)
\tkzDrawPoints(A,B,C,O_0,O_1,O_2,Z,I,H,B,D,E,F)
\tkzDrawPoints(D_1,E_1,F_1,G_1)
\tkzDrawPoints(D_2,E_2,F_2,G_2)
\tkzDrawPoints[red](F_1)
\tkzLabelPoints(A,B,C,O_0,O_2)
\tkzLabelPoints[below](O_1,G)
\tkzLabelPoints[above right](D,H)
\tkzLabelPoints[above left](E,E_1,E_2)
\tkzLabelPoints[below left](F,F_1,F_2)
\tkzLabelPoints(D_1,G_1)
\tkzLabelPoints(D_2,G_2)
\end{tikzpicture}
\end{Verbatim}

% subsection golden_arbelos (end)
% section examples (end)