summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tkz/tkz-euclide/latex/obj-lua/tkz-obj-lua-points.tex
blob: 4a81392c5d3fe05589584f0bfd7dc6de07b64f31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
 % tkz-obj-lua-points.tex
% Copyright 2023  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.00c}
\def\filedate{2023/01/23} 
\typeout{2023/01/23 5.00c  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