\newpage
\section{Class \tkzClass{quadrilateral}}

\vspace{1em}
The variable \tkzVar{quadrilateral}{Q} holds a table used to store quadrilaterals. It is optional, and you are free to choose the variable name. However, using \code{Q} is a recommended convention for clarity and consistency. If you use a custom variable (e.g., Quad), you must initialize it manually. The \tkzFct{tkz-elements}{init\_elements()} function reinitializes the \code{Q} table if used.


\subsection{Creating a quadrilateral}
\label{sub:creating_a_quadrilateral}
The \tkzClass{quadrilateral} class requires four points. The order defines the sides of the quadrilateral.

\medskip
The object is usually stored in \tkzVar{quadrilateral}{Q}, which is the recommended variable name.

\begin{mybox}
\begin{verbatim}
Q.ABCD = quadrilateral:new(z.A, z.B, z.C, z.D)
\end{verbatim}
\end{mybox}

\textbf{Short form.}

A shorthand constructor is also available:

\begin{mybox}
\begin{verbatim}
Q.ABCD = quadrilateral(z.A, z.B, z.C, z.D)
\end{verbatim}
\end{mybox}

\subsection{Quadrilateral Attributes}
Points are created in the direct direction. A test is performed to check whether the points form a rectangle, otherwise compilation is blocked.

\begin{center}
 \code{ Creation: Q.new = rectangle:new(z.A,z.B,z.C,z.D)}
\end{center}


  \bgroup
  \catcode`_=12
  \small
  \captionof{table}{rectangle attributes.}\label{quadrilateral:attributes}
  \begin{tabular}{lll}
  \toprule
  \textbf{Attributes}         & \textbf{Application} & \\
  \tkzAttr{quadrilateral}{pa}   & |z.A = Q.new.pa| & \\
  \tkzAttr{quadrilateral}{pb}   & |z.B = Q.new.pb| & \\
  \tkzAttr{quadrilateral}{pc}   & |z.C = Q.new.pc| & \\
  \tkzAttr{quadrilateral}{pd}   & |z.D = Q.new.pd| & \\
  \tkzAttr{quadrilateral}{type} & |Q.new.type= 'quadrilateral'|  &\\
  \tkzAttr{quadrilateral}{center}    & |z.I = Q.new.center| & intersection of diagonals\\
  \tkzAttr{quadrilateral}{g}    & |z.G = Q.new.g| & barycenter\\
  \tkzAttr{quadrilateral}{a}    & |AB = Q.new.a| & barycenter\\
  \tkzAttr{quadrilateral}{b}    & |BC = Q.new.b| & barycenter\\
  \tkzAttr{quadrilateral}{c}    & |CD = Q.new.c| & barycenter\\
  \tkzAttr{quadrilateral}{d}    & |DA = Q.new.d| & barycenter\\
  \tkzAttr{quadrilateral}{ab}   & |Q.new.ab|   &  line passing through two vertices   \\
  \tkzAttr{quadrilateral}{ac}   & |Q.new.ca|   &  idem. \\
  \tkzAttr{quadrilateral}{ad}   & |Q.new.ad|   &  idem. \\
  \tkzAttr{quadrilateral}{bc}   & |Q.new.bc|   &  idem. \\
  \tkzAttr{quadrilateral}{bd}   & |Q.new.bd|   &  idem. \\
  \tkzAttr{quadrilateral}{cd}   & |Q.new.cd|   &  idem. \\
  \bottomrule
  \end{tabular}
  \egroup


\subsubsection{Quadrilateral attributes}

\vspace{1em}
\begin{minipage}{.5\textwidth}
\begin{verbatim}
\directlua{
init_elements()
z.A = point(0, 0)
z.B = point(4, 0)
z.C = point(5, 1)
z.D = point(0, 3)
Q.ABCD = quadrilateral(z.A, z.B, z.C, z.D)
z.I = Q.ABCD.i
z.G = Q.ABCD.g}

\begin{tikzpicture}
\tkzGetNodes
\tkzDrawPolygon(A,B,C,D)
\tkzDrawSegments(A,C B,D)
\tkzDrawPoints(A,B,C,D,I,G)
\end{tikzpicture}
\end{verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{
 init_elements()
 z.A = point(0, 0)
 z.B = point(4, 0)
 z.C = point(5, 1)
 z.D = point(0, 3)
 Q.ABCD = quadrilateral(z.A, z.B, z.C, z.D)
 z.I = Q.ABCD.center
 z.G = Q.ABCD.g}

\begin{center}
  \begin{tikzpicture}
  \tkzGetNodes
  \tkzDrawPolygon(A,B,C,D)
  \tkzDrawSegments(A,C B,D)
  \tkzDrawPoints(A,B,C,D,I,G)
  \end{tikzpicture}
\end{center}
\end{minipage}

\subsubsection{Quadrilateral examples}
Advanced Euclidean Geometry 2013 Supplement June 26\\

\texttt{Construction of geometric mean: }


\directlua{
init_elements()
z.A = point(0, 0)
z.B = point(1, 4)
z.C = point(3.5, 4)
z.D = point(5, 0 )
Q.ABCD = quadrilateral(z.A, z.B, z.C, z.D)
z.I = Q.ABCD.center
L.ll = Q.ABCD.da:ll_from(z.I)
z.H = intersection(L.ll, Q.ABCD.ab)
z.Hp = intersection(L.ll, Q.ABCD.cd)
z.M =  Q.ABCD.ab.mid
C.MA = circle(z.M, z.A)
L.perp = Q.ABCD.ab:ortho_from(z.H)
_,z.P = intersection (C.MA, L.perp)
T.PAB = triangle (z.P, z.A, z.B)
L.bis =  T.PAB:bisector ()
z.G = L.bis.pb
L.llg = Q.ABCD.da:ll_from(z.G)
L.llm = Q.ABCD.da:ll_from(z.M)
z.Gp = intersection(L.llg, Q.ABCD.cd)}
\begin{center}
\begin{tikzpicture}
\tkzGetNodes
\tkzDrawPolygon(A,B,C,D)
\tkzDrawCircle(M,A)
\tkzDrawSegments[red](H,H')
\tkzDrawSegments[blue](G,G')
\tkzDrawSegments[dashed](P,H P,B P,A P,G A,C B,D)
\tkzDrawPoints(A,B,C,D,H,I,M,P,G,G',H')
\tkzLabelPoints(A,D,I)
\tkzLabelPoints[above](B,C,P)
\tkzLabelPoints[above right=-3pt](H,G)
\tkzLabelPoints[right](G',H')
 \tkzLabelSegment[above](B,C){$b$}
 \tkzLabelSegment[below](A,D){$a$}
\end{tikzpicture}
\end{center}



\begin{proof}
A trapezoid with parallel sides $AD$ and $BC$ is given.

Let H be the endpoint of the parallel through $I$
to the side $AD$.  $HH' = \dfrac{2ab}{a+b}$ .

$PH$ is perpendicular to $AB$

$(PG)$ is the bisector of $\widehat{APB}$

 $GG' = \dfrac{a \cdot \sqrt{b} + b \cdot \sqrt{a}}{\sqrt{a}+\sqrt{b}}
= \dfrac{\sqrt{ab}(\sqrt{a}+\sqrt{b})}{\sqrt{a}+\sqrt{b}} = \sqrt{ab} $
\end{proof}

\texttt{Code: }

\begin{verbatim}
\directlua{
init_elements()
z.A = point(0, 0)
z.B = point(1, 4)
z.C = point(3.5, 4)
z.D = point(5, 0 )
Q.ABCD = quadrilateral(z.A, z.B, z.C, z.D)
z.I = Q.ABCD.center
L.ll = Q.ABCD.da:ll_from (z.I)
z.H = intersection(L.ll, Q.ABCD.ab)
z.Hp = intersection(L.ll, Q.ABCD.cd)
z.M =  Q.ABCD.ab.mid
C.MA = circle(z.M,z.A)
L.perp = Q.ABCD.ab:ortho_from(z.H)
_,z.P = intersection(C.MA, L.perp)
T.PAB = triangle(z.P, z.A, z.B)
L.bis =  T.PAB:bisector()
z.G = L.bis.pb
L.llg = Q.ABCD.da:ll_from(z.G)
L.llm = Q.ABCD.da:ll_from(z.M)
z.Gp = intersection(L.llg, Q.ABCD.cd)}
\end{verbatim}

\subsection{Quadrilateral methods}

\vspace{1em}

  \bgroup
  \catcode`_=12
  \small
  \captionof{table}{Quadrilateral methods.}\label{quadrilateral:methods}
  \begin{tabular}{ll}
  \toprule
  \textbf{Methods} & \texttt{Reference}    \\
  \midrule
  \tkzMeth{quadrilateral}{new()}& Note\footnote{quadrilateral(pt, pt, pt, pt) (short form, recommended)}; [\ref{sub:creating_a_quadrilateral}]\\

  \tkzMeth{quadrilateral}{is\_cyclic ()} & [\ref{ssub:iscyclic}]\\
  \tkzMeth{quadrilateral}{is\_convex ()} & [\ref{ssub:isconvex}]\\
  \tkzMeth{quadrilateral}{poncelet\_point()} & [\ref{ssub:poncelet_point}]\\
  \bottomrule %
  \end{tabular}
  \egroup



\subsubsection{Method \tkzMeth{quadrilateral}{is\_cyclic()}}
\label{ssub:iscyclic}

\textbf{Inscribed quadrilateral}

\vspace{1em}
\begin{minipage}{.5\textwidth}
\begin{verbatim}
\directlua{
 init_elements()
 z.A = point(0, 0)
 z.B = point(4, 0)
 z.D = point:polar(4, tkz.tau / 3)
 L.DB = line(z.D, z.B)
 T.equ = L.DB:equilateral()
 z.C = T.equ.pc
 Q.new = quadrilateral(z.A, z.B, z.C, z.D)
 bool = Q.new:is_cyclic()
 if bool == true then
 	C.cir = triangle(z.A, z.B, z.C):
   circum_circle()
 	z.O = C.cir.center
 end}
\begin{tikzpicture}
  \tkzGetNodes
  \tkzDrawPolygon(A,B,C,D)
  \tkzDrawPoints(A,B,C,D)
  \tkzDrawCircle(O,A)
  \ifthenelse{\equal{\tkzUseLua{bool}}{
     true}}{\tkzDrawCircle(O,A)}{}
  \tkzLabelPoints(A,B)
  \tkzLabelPoints[above](C,D)
\end{tikzpicture}
\end{verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\directlua{
init_elements()
z.A = point(0, 0)
z.B = point(4, 0)
z.D = point:polar(4, tkz.tau / 3)
L.DB = line(z.D, z.B)
T.equ = L.DB:equilateral()
z.C = T.equ.pc
Q.new = quadrilateral(z.A, z.B, z.C, z.D)
bool = Q.new:is_cyclic()
if bool == true then
	C.cir = triangle(z.A, z.B, z.C):circum_circle()
	z.O = C.cir.center
end
}
\begin{center}
\begin{tikzpicture}[scale = .75]
  \tkzGetNodes
  \tkzDrawPolygon(A,B,C,D)
  \tkzDrawPoints(A,B,C,D)
  \tkzDrawCircle(O,A)
  \ifthenelse{\equal{\tkzUseLua{bool}}{
   true}}{\tkzDrawCircle(O,A)}{}
  \tkzLabelPoints(A,B)
  \tkzLabelPoints[above](C,D)
\end{tikzpicture}
\end{center}
\end{minipage}

\subsubsection{Method \tkzMeth{quadrilateral}{is\_convex()}}
\label{ssub:isconvex}







\subsubsection{Method \tkzMeth{quadrilateral}{poncelet\_point}}
\label{ssub:poncelet_point}

See [\ref{ssub:method_triangle_poncelet_point}] for the definition.

\begin{tkzexample}[latex=.5\textwidth]
\directlua{
 init_elements()
 z.A = point(1, 1)
 z.B = point(6, 0)
 z.D = point(0, 5)
 z.C = point(6, 2)
 Q.ABCD = quadrilateral(z.A, z.B, z.C, z.D)
 z.P = Q.ABCD:poncelet_point()
 T.ABC = triangle(z.A,z.B,z.C)
 z.I = T.ABC.eulercenter
 z.Mc = tkz.midpoint(z.A, z.B)
 T.ABD = triangle(z.A, z.B, z.D)
 z.I1 = T.ABD.eulercenter}
\begin{center}
\begin{tikzpicture}
  \tkzGetNodes
  \tkzDrawPolygons(A,B,C,D)
  \tkzDrawPoints(A,B,C,D,P,Mc)
  \tkzDrawCircles[red](I,Mc I1,Mc)
  \tkzLabelPoints(A,B)
  \tkzLabelPoints[above](C,D,P)
\end{tikzpicture}
\end{center}
\end{tkzexample}
\endinput