% !TEX TS-program = lualatex
% Author Alain Matthes 2023
\documentclass{article}
\usepackage{tkz-euclide}
\usepackage{tkz-elements}
\begin{document}

\begin{tkzelements}
   scale = 2
   z.A                  = point: new (0 , 0)
   z.B                  = point: new (5 , 1)
   L.AB                 = line : new (z.A,z.B)
   z.C                  = point: new (.8 , 3)
   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) 
   E                    = ellipse: foci (z.H,z.O,z.I)  
   a                    = E.Rx
   b                    = E.Ry
   ang                  = math.deg(E.slope)
   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)
    set_lua_to_tex {'a','b','ang'} 
 \end{tkzelements}

\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPolygon(A,B,C)
   \tkzDrawCircles[red](N,Ma O,A)
   \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)
   \tkzDrawEllipse[blue](N,\a,\b,\ang)
\end{tikzpicture}
\end{document}

