Debian Codegraph @

texmf-dist/tex/latex/tkz-base/tkz-obj-points.tex

raw
1 % tkz-obj-eu-points.tex
2 % Copyright 2024 Alain Matthes
3 % This work may be distributed and/or modified under the
4 % conditions of the LaTeX Project Public License, either version 1.3
5 % of this license or (at your option) any later version.
6 % The latest version of this license is in
7 % http://www.latex-project.org/lppl.txt
8 % and version 1.3 or later is part of all distributions of LaTeX
9 % version 2005/12/01 or later.
10 % This work has the LPPL maintenance status “maintained”.
11 % The Current Maintainer of this work is Alain Matthes.
12
13 \def\fileversion{4.21c}
14 \def\filedate{2024/01/16 }
15 \typeout{2024/01/16 4.21c tkz-obj-points.tex}
16 \makeatletter
17 %<--------------------------------------------------------------------------->
18 % init def point
19 %<--------------------------------------------------------------------------->
20 % tkzDefPoint
21 %<--------------------------------------------------------------------------->
22 % macros complémentaires pour def point
23 %<--------------------------------------------------------------------------->
24 \def\tkz@parsecoordinate#1{%
25 \tkz@getseparator#1,\@nil
26 \iftkz@polar
27 \tkz@getfrompolar#1\@nil
28 \else
29 \tkz@getfromcart#1\@nil
30 \fi
31 }
32 \def\tkz@getseparator#1,#2\@nil{%
33 \ifx\tkzempty#2\tkzempty%
34 \tkz@polartrue
35 \else
36 \tkz@polarfalse
37 \fi
38 }
39 \def\tkz@getfrompolar#1:#2\@nil{%
40 \edef\tkz@a{\fpeval{#1}}
41 \edef\tkz@r{\fpeval{#2}}
42 \xdef\tkz@polarrad{\tkz@r}
43 \xdef\tkz@polarangle{\tkz@a}
44 }
45 \def\tkz@getfromcart#1,#2\@nil{%
46 \edef\tkz@x{\fpeval{#1}}
47 \edef\tkz@y{\fpeval{#2}}
48 \xdef\tkz@absc{\tkz@x}
49 \xdef\tkz@ord{\tkz@y}
50 }
51 %<--------------------------------------------------------------------------->
52 % options pour point definition
53 %<--------------------------------------------------------------------------->
54 \pgfkeys{/tkzPt/.cd,
55 polar/.is if = tkz@pt@polar,
56 polar/.default = true,
57 polar = false
58 }
59 %<--------------------------------------------------------------------------->
60 % tkz@ptStar
61 %<--------------------------------------------------------------------------->
62 \def\tkz@ptStar[#1](#2,#3)#{%
63 \pgfkeys{/tkzPt/.cd, polar = false}
64 \pgfqkeys{/tkzPt}{#1}
65 \iftkz@pt@polar%
66 \edef\tkz@x{\fpeval{#3*cosd(#2)}}
67 \edef\tkz@y{\fpeval{#3*sind(#2)}}
68 \else
69 \edef\tkz@x{\fpeval{#2}}
70 \edef\tkz@y{\fpeval{#3}}
71 \fi
72 \edef\tkzpt@xa{\fpeval{(\tkz@x-\tkz@init@xorigine)/\tkz@init@xstep}}
73 \edef\tkzpt@ya{\fpeval{(\tkz@y-\tkz@init@yorigine)/\tkz@init@ystep}}
74 \tkz@node
75 }
76 %<--------------------------------------------------------------------------->
77 % la macro defpoint les coordonnées cartésiennes ou polaires sont traitées
78 % afin de pouvoir être adaptées avec les unités choisies
79 %<--------------------------------------------------------------------------->
80 \def\tkzDefPoint{\pgfutil@ifnextchar[{\tkz@DefPoint}{\tkz@DefPoint[]}}
81
82 \def\tkz@DefPoint[#1](#2)#{%
83 \tkz@parsecoordinate{#2}
84 \iftkz@polar
85 \tkz@ptStar[polar](\tkz@polarangle,\tkz@polarrad){tkz@coord@temp}
86 \else
87 \tkz@ptStar[](#2){tkz@coord@temp}
88 \fi
89 \tkz@DefPointEnd[#1]
90 }%
91 \def\tkz@DefPointEnd[#1]#2{\coordinate[#1] (#2) at (tkz@coord@temp);}
92 %<--------------------------------------------------------------------------->
93 % tkzDefPoints
94 %<--------------------------------------------------------------------------->
95 \def\tkzDefPoints{\pgfutil@ifnextchar[{\tkz@DefPoints}{\tkz@DefPoints[]}}
96 \def\tkz@DefPoints[#1]#2{%
97 \begingroup
98 \def\tkz@parenthesis@for@err{(}%
99 \def\tkz@maybe@parenthesis{#2}%
100 \ifx\tkz@maybe@parenthesis\tkz@parenthesis@for@err
101 \PackageError{tkz-base}{Syntax error use {} instead of ()}{You need to use {} instead of ()}%
102 \expandafter\@firstoftwo
103 \else
104 \expandafter\@secondoftwo
105 \fi
106 {\tkz@absorb@bad@arg}%
107 {\foreach \ptx/\pty/\name in {#2}{\tkzDefPoint[#1](\ptx,\pty){\name}}%
108 \endgroup}%
109 }
110 \def\tkz@absorb@bad@arg#1){\endgroup}
111 %<--------------------------------------------------------------------------->
112 \def\tkz@node#1{ \pgfinterruptboundingbox
113 \path[coordinate](\tkzpt@xa,\tkzpt@ya) coordinate(#1);
114 \endpgfinterruptboundingbox}
115 % \def\tkz@drawnode#1{\path[coordinate](\tkzpt@xa,\tkzpt@ya) coordinate(#1);
116 % \tkz@DrawPt{#1}
117 % }
118 %<--------------------------------------------------------------------------->
119 %
120 %<--------------------------------------------------------------------------->
121 \def\tkzRenamePoint(#1)#2{\coordinate (#2) at (#1);}
122 \def\tkz@RenamePointEnd[#1]#2{\coordinate[#1] (#2) at (\tkz@ax,\tkz@ay);}
123 \def\tkzGetPoint#1{\coordinate (#1) at (tkzPointResult);}
124 \def\tkzGetPoints#1#2{\coordinate (#1) at (tkzFirstPointResult);
125 \coordinate (#2) at (tkzSecondPointResult);}
126 \def\tkzGetFirstPoint#1{\coordinate (#1) at (tkzFirstPointResult);}
127 \def\tkzGetSecondPoint#1{\coordinate (#1) at (tkzSecondPointResult);}
128 \def\tkzDefShiftPointCoord[#1](#2)#3{%
129 \begin{scope}[shift={(#1)}]
130 \coordinate (#3) at (#2);
131 \end{scope}
132 }%
133 %<--------------------------------------------------------------------------->
134 % tkzDefShiftPoint
135 %<--------------------------------------------------------------------------->
136 \def\tkzDefShiftPoint[#1](#2)#3{%
137 \tkz@@extractxy{#1}
138 \tkz@ax\pgf@x %
139 \tkz@ay\pgf@y %
140 \begin{scope}[shift={(\tkz@ax,\tkz@ay)}]
141 \coordinate (#3) at (#2);
142 \end{scope}
143 }
144 %<--------------------------------------------------------------------------->
145 % Coordonnées d'un point
146 % result in #2x et #2y #1 est le point et on récupère ses coordonnées
147 % usage soit A un point \tkzGetPointCoord(A){V} alors \Vx = xA et \Vy = yA
148 % en cm
149 % tkzGetPointCoord avec [#1] cm ou bien pt ?? todo
150 %<--------------------------------------------------------------------------->
151 \def\tkzGetPointCoord(#1)#2{%
152 \begingroup
153 \pgfextractx{\pgf@x}{\pgfpointanchor{#1}{center}}
154 \pgfmathparse{\pgf@sys@tonumber{\pgf@x}/28.45274}
155 \global\let\tkzresultx\pgfmathresult
156 \global\expandafter\edef\csname #2x\endcsname{\tkzresultx}%
157 \pgfextracty{\pgf@y}{\pgfpointanchor{#1}{center}}
158 \pgfmathparse{\pgf@sys@tonumber{\pgf@y}/28.45274}
159 \global\let\tkzresulty\pgfmathresult
160 \global\expandafter\edef\csname #2y\endcsname{\tkzresulty}
161 \endgroup
162 }
163 \def\tkz@@extractxy#1{%
164 \pgfextractx{\pgf@x}{\pgfpointanchor{#1}{center}}
165 \pgfextracty{\pgf@y}{\pgfpointanchor{#1}{center}}
166 }
167 \let\tkzGetPointxy\tkzGetPointCoord
168 %<--------------------------------------------------------------------------->
169 %%%%%%%%%. Label,draw
170 %<-------------------------------------------------------------------------->
171 % tkzLabelPoint Affichage des LABELS pour un point
172 %<-------------------------------------------------------------------------->
173 \def\tkzLabelPoint{\pgfutil@ifnextchar[{\tkz@LabelPoint}{\tkz@LabelPoint[]}}
174 \def\tkz@LabelPoint[#1](#2)#3{%
175 \node[label style,#1] at (#2) {#3};}%
176 %<--------------------------------------------------------------------------->
177
178 \def\tkzLabelPoints{\pgfutil@ifnextchar[{\tkz@LabelPoints}{\tkz@LabelPoints[]}}%
179 \def\tkz@LabelPoints[#1](#2){%
180 \foreach \point in {#2}{
181 \node[label style,#1] at (\point) {$\point$};}
182 }%
183 %<--------------------------------------------------------------------------->
184 \pgfkeys{/tkzsetuppt/.cd,
185 size/.store in = \tkz@pt@size,
186 color/.store in = \tkz@pt@color,
187 fill/.store in = \tkz@pt@fill,
188 shape/.store in = \tkz@pt@shape,
189 size = \tkz@euc@pointsize,
190 color = \tkz@euc@pointcolor,
191 fill = \tkz@euc@pointcolor,
192 shape = \tkz@euc@pointshape,
193 /tkzsetuppt/.search also = {/tikz},
194 }
195 \def\tkzSetUpPoint{\pgfutil@ifnextchar[{\tkz@SetUpPoint}{%
196 \tkz@SetUpPoint[]}}
197 \def\tkz@SetUpPoint[#1]{%
198 \pgfqkeys{/tkzsetuppt}{#1}
199 % redefine point style with new values
200 \tikzset{point style/.style={draw = \tkz@pt@color,
201 inner sep = 0pt,
202 shape = \tkz@pt@shape,
203 minimum size = \tkz@pt@size,
204 fill = \tkz@pt@fill}}
205 }% end setup
206 %<--------------------------------------------------------------------------->
207 %
208 %<--------------------------------------------------------------------------->
209 \def\tkzSetUpLabel{\pgfutil@ifnextchar[{\tkz@SetUpLabel}{%
210 \tkz@SetUpLabel[]}}
211 \def\tkz@SetUpLabel[#1]{%
212 \tikzset{label style/.style={#1}}
213 }% end setup
214 %<--------------------------------------------------------------------------->
215
216 \pgfkeys{/tkzautolab/.cd,
217 center/.store in = \tkz@center,
218 dist/.store in = \tkz@dist,
219 dist = 0.15,
220 /tkzautolab/.search also = {/tikz},
221 }
222 \def\tkzAutoLabelPoints{\pgfutil@ifnextchar[{\tkz@AutoLabelPoints}{\tkz@AutoLabelPoints[]}}%
223 \def\tkz@AutoLabelPoints[#1](#2){%
224 \begingroup
225 \pgfqkeys{/tkzautolab}{#1}
226 \foreach \point in {#2}{
227 \path (\tkz@center) -- ($ (\point) + \tkz@dist*($(\point)-(\tkz@center)$) $) node[/tkzautolab/.cd,label style,#1]{$\point$};}
228 \endgroup
229 }%
230 %<--------------------------------------------------------------------------->
231 % tkzSetUpPoint définit la forme d'un point
232 %<--------------------------------------------------------------------------->
233 \pgfkeys{/tkzsetuppt/.cd,
234 size/.store in = \tkz@pt@size,
235 color/.store in = \tkz@pt@color,
236 fill/.store in = \tkz@pt@fill,
237 shape/.store in = \tkz@pt@shape,
238 size = \tkz@euc@pointsize,
239 color = \tkz@euc@pointcolor,
240 fill = \tkz@euc@pointcolor,
241 shape = \tkz@euc@pointshape,
242 /tkzsetuppt/.search also = {/tikz},
243 }
244 \def\tkzSetUpPoint{\pgfutil@ifnextchar[{\tkz@SetUpPoint}{%
245 \tkz@SetUpPoint[]}}
246 \def\tkz@SetUpPoint[#1]{%
247 \pgfqkeys{/tkzsetuppt}{#1}
248 % redefine point style with new values
249 \tikzset{point style/.style={draw = \tkz@pt@color,
250 inner sep = 0pt,
251 shape = \tkz@pt@shape,
252 minimum size = \tkz@pt@size,
253 fill = \tkz@pt@fill}}
254 }% end setup
255 %<--------------------------------------------------------------------------->
256 % Draw Point
257 %<--------------------------------------------------------------------------->
258 \pgfkeys{/tkzdrawpt/.cd,
259 size/.code = {\tikzset{point style/.append style={minimum size = #1}}},
260 size = \tkz@euc@pointsize,
261 /tkzdrawpt/.search also = {/tikz},
262 }
263 %<--------------------------------------------------------------------------
264 \def\tkzDrawPoint{\pgfutil@ifnextchar[{\tkz@DrawPoint}{\tkz@DrawPoint[]}}
265 \def\tkz@DrawPoint[#1](#2){%
266 \begingroup
267 \pgfqkeys{/tkzdrawpt}{#1}
268 \node[point style,/tkzdrawpt/.cd,#1] at (#2) {};%2016
269 \endgroup
270 }
271 %<--------------------------------------------------------------------------->
272 \def\tkzDrawPoints{\pgfutil@ifnextchar[{\tkz@drawpts}{\tkz@drawpts[]}}
273 %<--------------------------------------------------------------------------->
274 \def\tkz@drawpts[#1](#2){%
275 \begingroup
276 \pgfqkeys{/tkzdrawpt}{#1}
277 \foreach \point in {#2}{\node[point style,/tkzdrawpt/.cd,#1] at (\point) {};} %2016
278 \endgroup
279 }
280 %<--------------------------------------------------------------------------->
281 % PointShowCoord
282 %<--------------------------------------------------------------------------->
283 \pgfkeys{/tkzprcoord/.cd,
284 xlabel/.store in = \tkz@xlabel,
285 ylabel/.store in = \tkz@ylabel,
286 xstyle/.code = {\tikzset{xcoord style/.append style={#1}}},
287 ystyle/.code = {\tikzset{ycoord style/.append style={#1}}},
288 noxdraw/.is if = tkz@coord@noxdraw,
289 noxdraw/.default = true,
290 noydraw/.is if = tkz@coord@noydraw,
291 noydraw/.default = true,
292 xlabel = {},
293 ylabel = {},
294 xstyle = {},
295 ystyle = {},
296 noxdraw = false,
297 noydraw = false,
298 /tkzprcoord/.search also = {/tikz},
299 }
300 \def\tkzPointShowCoord{\pgfutil@ifnextchar[{\tkz@PointShowCoord}{\tkz@PointShowCoord[]}}
301 \def\tkz@PointShowCoord[#1](#2){%
302 \begingroup
303 \pgfqkeys{/tkzprcoord}{#1}
304 % 2019 for showcoord
305 \iftkznodedefined{tkz@xline}{}{%
306 \path (0,0) --(1,0) node(tkz@xline){};
307 \path (0,0) --(0,1) node(tkz@yline){};
308 }
309 \iftkz@coord@noxdraw\else\draw[arrow coord style,/tkzprcoord/.cd,#1] (#2)--(#2 |- tkz@xline);\fi
310 \iftkz@coord@noydraw\else\draw[arrow coord style,/tkzprcoord/.cd,#1] (#2)--(#2 -| tkz@yline);\fi
311 \ifx\tkzutil@empty\tkz@xlabel
312 \else
313 \path (#2)--(#2 |- tkz@xline)
314 node[xcoord style] {\tkz@xlabel};
315 \fi
316 \ifx\tkzutil@empty\tkz@ylabel
317 \else
318 \path (#2)--(#2 -| tkz@yline)
319 node[ycoord style] {\tkz@ylabel};
320 \fi
321 \endgroup
322 }
323 \let\tkzShowPointCoord\tkzPointShowCoord
324 \makeatother
325 \endinput