% !TEX TS-program = lualatex
% Created by Alain Matthes on 2024-12-25.
% Copyright (c) 2024 AlterMundus.
\documentclass[margin = 12pt]{standalone} 
\usepackage[mini]{tkz-euclide}
\usepackage{tkz-elements}
\begin{document} 

% The Feuerbach triangle is the triangle formed by the three points of tangency of the nine-point circle with the excircles    

\directlua{
  z.A = point(0, 0)
  z.B = point(6, 0)
  z.C = point(0.8, 4)
  T.ABC = triangle(z.A, z.B, z.C)
  z.N = T.ABC.eulercenter
  z.S = T.ABC.spiekercenter
  T.feuerbach = T.ABC:feuerbach()
  z.Ea, z.Eb, z.Ec = T.feuerbach:get()
  T.excentral = T.ABC:excentral()
  z.Ja, z.Jb, z.Jc = T.excentral:get()
  C.JaEa = circle:new(z.Ja, z.Ea)
  % C.ortho = circle:radius(z.S, math.sqrt(C.JaEa:power(z.S)))
  C.ortho = C.JaEa:orthogonal_from(z.S)
  z.a = C.ortho.through
  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 = .6]
   \tkzGetNodes
   \tkzFillCircles[green!30](O,xa)
   \tkzFillCircles[teal!30](Ja,Ea Jb,Eb Jc,Ec)
   \tkzFillCircles[lightgray](S,a)
   \tkzFillCircles[green!30](N,Ea)
   \tkzDrawPoints(xa,xb,xc)
   \tkzClipCircle(O,xa)
   \tkzDrawLines[add=3 and 3](A,B A,C B,C)
   \tkzDrawCircles(Ja,Ea Jb,Eb Jc,Ec S,a O,xa N,Ea)
   \tkzDrawPoints(O,A,B,C,S,Ea,Eb,Ec,N)
   \tkzDrawSegments[dashed](S,xa S,xb S,xc)
   \tkzLabelPoints(O,N,A,B)
   \tkzLabelPoints[right](S,C)
\end{tikzpicture}

\end{document}


           
