 % tkz-obj-lua-points.tex
% Copyright 2011-2026  Alain Matthes
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
% This work has the LPPL maintenance status “maintained”. 
% The Current Maintainer of this work is Alain Matthes.

\def\fileversion{5.11c}
\def\filedate{2026/01/22} 
\typeout{2026/01/22 5.12c  tkz-obj-lua-points.tex} 
\makeatletter
%<--------------------------------------------------------------------------->
%                             init def point 
%<--------------------------------------------------------------------------->
%                            tkzDefPoint
%<--------------------------------------------------------------------------->
%                     macros complémentaires  pour def point
%<--------------------------------------------------------------------------->
\def\tkz@parsecoordinate#1{%
\tkz@getseparator#1,\@nil
\iftkz@polar 
   \tkz@getfrompolar#1\@nil
\else
   \tkz@getfromcart#1\@nil
\fi
}
\def\tkz@getseparator#1,#2\@nil{%
\ifx\tkzempty#2\tkzempty%
   \tkz@polartrue
\else
   \tkz@polarfalse
\fi
}      
\def\tkz@getfrompolar#1:#2\@nil{%
\edef\tkz@a{\fpeval{#1}}
\edef\tkz@r{\fpeval{#2}}
\xdef\tkz@polarrad{\tkz@r}
\xdef\tkz@polarangle{\tkz@a}
} 
\def\tkz@getfromcart#1,#2\@nil{%
\edef\tkz@x{\fpeval{#1}}
\edef\tkz@y{\fpeval{#2}}
\xdef\tkz@absc{\tkz@x}
\xdef\tkz@ord{\tkz@y}
}
%<--------------------------------------------------------------------------->
%           options pour point definition
%<--------------------------------------------------------------------------->
\pgfkeys{/tkzPt/.cd,  
         polar/.is if       = tkz@pt@polar,
         polar/.default     = true,
         polar              = false  
}
%<--------------------------------------------------------------------------->
%        tkz@ptStar  
%<--------------------------------------------------------------------------->
\def\tkz@ptStar[#1](#2,#3)#{%
\pgfkeys{/tkzPt/.cd, polar     = false} 
\pgfqkeys{/tkzPt}{#1}  
\iftkz@pt@polar%
  \edef\tkz@x{\fpeval{#3*cosd(#2)}}
  \edef\tkz@y{\fpeval{#3*sind(#2)}}
\else
  \edef\tkz@x{\fpeval{#2}}
  \edef\tkz@y{\fpeval{#3}}
\fi
\edef\tkzpt@xa{\tkz@Dec{(\tkz@x-(\tkz@init@xorigine))/\tkz@init@xstep}}
\edef\tkzpt@ya{\tkz@Dec{(\tkz@y-(\tkz@init@yorigine))/\tkz@init@ystep}}
\tkz@node
}
%<--------------------------------------------------------------------------->
% la macro defpoint les coordonnées cartésiennes ou polaires sont  traitées
% afin de pouvoir être adaptées avec les unités choisies
%<--------------------------------------------------------------------------->
\def\tkzDefPoint{\pgfutil@ifnextchar[{\tkz@DefPoint}{\tkz@DefPoint[]}}

\def\tkz@DefPoint[#1](#2)#{% 
\tkz@parsecoordinate{#2}
\iftkz@polar
   \tkz@ptStar[polar](\tkz@polarangle,\tkz@polarrad){tkz@coord@temp}
\else  
    \tkz@ptStar[](#2){tkz@coord@temp}
\fi
\tkz@DefPointEnd[#1]
}% 
\def\tkz@DefPointEnd[#1]#2{\coordinate[#1] (#2) at (tkz@coord@temp);}
%<--------------------------------------------------------------------------->
%                            tkzDefPoints
%<--------------------------------------------------------------------------->
\def\tkzDefPoints{\pgfutil@ifnextchar[{\tkz@DefPoints}{\tkz@DefPoints[]}}
\def\tkz@DefPoints[#1]#2{%
  \begingroup
  \def\tkz@parenthesis@for@err{(}%
  \def\tkz@maybe@parenthesis{#2}%
  \ifx\tkz@maybe@parenthesis\tkz@parenthesis@for@err
    \PackageError{tkz-base}{Syntax error  use {} instead of ()}{You need to use {} instead of ()}%
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {\tkz@absorb@bad@arg}% 
  {\foreach \ptx/\pty/\name in {#2}{\tkzDefPoint[#1](\ptx,\pty){\name}}%
   \endgroup}%
}
\def\tkz@absorb@bad@arg#1){\endgroup}
%<--------------------------------------------------------------------------->
\def\tkz@node#1{ \pgfinterruptboundingbox
\path[coordinate](\tkzpt@xa,\tkzpt@ya) coordinate(#1);
 \endpgfinterruptboundingbox}  
%<--------------------------------------------------------------------------->
\def\tkzRenamePoint(#1)#2{\coordinate (#2) at (#1);}
\def\tkz@RenamePointEnd[#1]#2{\coordinate[#1] (#2) at (\tkz@ax,\tkz@ay);}
\def\tkzGetPoint#1{\coordinate  (#1) at (tkzPointResult);} 
\def\tkzGetPoints#1#2{\coordinate  (#1) at (tkzFirstPointResult);
                      \coordinate  (#2) at (tkzSecondPointResult);}
\def\tkzGetFirstPoint#1{\coordinate  (#1) at (tkzFirstPointResult);}
\def\tkzGetSecondPoint#1{\coordinate  (#1) at (tkzSecondPointResult);}
\def\tkzGetThirdPoint#1{\coordinate  (#1) at (tkzThirdPointResult);}
\def\tkzDefShiftPointCoord[#1](#2)#3{%
                \begin{scope}[shift={(#1)}]
                     \coordinate  (#3) at (#2);
                \end{scope}
                           }%
%<--------------------------------------------------------------------------–>
%<--------------------------------------------------------------------------->
%            tkzDefShiftPoint
%<--------------------------------------------------------------------------->
\def\tkzDefShiftPoint[#1](#2)#3{%
   \tkz@@extractxy{#1}
   \tkz@ax\pgf@x %
   \tkz@ay\pgf@y %
\begin{scope}[shift={(\tkz@ax,\tkz@ay)}]
   \coordinate  (#3) at (#2);
\end{scope}
}
%<--------------------------------------------------------------------------->
%                    Coordonnées d'un point 
%    result in #2x et #2y    #1 est le point et on récupère ses coordonnées
% usage soit A un point \tkzGetPointCoord(A){V} alors \Vx = xA et \Vy = yA
% en cm 
% tkzGetPointCoord avec [#1] cm ou bien pt ?? todo
%<--------------------------------------------------------------------------->
\def\tkzGetPointCoord(#1)#2{%
\begingroup
   \pgfextractx{\pgf@x}{\pgfpointanchor{#1}{center}}
   \pgfmathparse{\pgf@sys@tonumber{\pgf@x}/28.45274}
   \global\let\tkzresultx\pgfmathresult
   \global\expandafter\edef\csname #2x\endcsname{\tkzresultx}% 
   \pgfextracty{\pgf@y}{\pgfpointanchor{#1}{center}}
   \pgfmathparse{\pgf@sys@tonumber{\pgf@y}/28.45274}
   \global\let\tkzresulty\pgfmathresult
   \global\expandafter\edef\csname #2y\endcsname{\tkzresulty}
\endgroup
}  
\def\tkz@@extractxy#1{%
\pgfextractx{\pgf@x}{\pgfpointanchor{#1}{center}}
\pgfextracty{\pgf@y}{\pgfpointanchor{#1}{center}} 
}
\let\tkzGetPointxy\tkzGetPointCoord
\makeatother
\endinput