Debian Codegraph @

texmf-dist/tex/latex/tkz-euclide/tkz-obj-eu-lua-points.tex

raw
1 % tkz-obj-lua-points.tex
2 % Copyright 2011-2026 Alain Matthes
3 % SPDX-License-Identifier: LPPL-1.3c
4 % Maintainer: Alain Matthes
5
6 \typeout{2026/01/25 5.13c tkz-obj-lua-points.tex}
7 \makeatletter
8 %<--------------------------------------------------------------------------->
9 % init def point
10 %<--------------------------------------------------------------------------->
11 % tkzDefPoint
12 %<--------------------------------------------------------------------------->
13 % macros complémentaires pour def point
14 %<--------------------------------------------------------------------------->
15 \def\tkz@parsecoordinate#1{%
16 \tkz@getseparator#1,\@nil
17 \iftkz@polar
18 \tkz@getfrompolar#1\@nil
19 \else
20 \tkz@getfromcart#1\@nil
21 \fi
22 }
23 \def\tkz@getseparator#1,#2\@nil{%
24 \ifx\tkzempty#2\tkzempty%
25 \tkz@polartrue
26 \else
27 \tkz@polarfalse
28 \fi
29 }
30 \def\tkz@getfrompolar#1:#2\@nil{%
31 \edef\tkz@a{\fpeval{#1}}
32 \edef\tkz@r{\fpeval{#2}}
33 \xdef\tkz@polarrad{\tkz@r}
34 \xdef\tkz@polarangle{\tkz@a}
35 }
36 \def\tkz@getfromcart#1,#2\@nil{%
37 \edef\tkz@x{\fpeval{#1}}
38 \edef\tkz@y{\fpeval{#2}}
39 \xdef\tkz@absc{\tkz@x}
40 \xdef\tkz@ord{\tkz@y}
41 }
42 %<--------------------------------------------------------------------------->
43 % options pour point definition
44 %<--------------------------------------------------------------------------->
45 \pgfkeys{/tkzPt/.cd,
46 polar/.is if = tkz@pt@polar,
47 polar/.default = true,
48 polar = false
49 }
50 %<--------------------------------------------------------------------------->
51 % tkz@ptStar
52 %<--------------------------------------------------------------------------->
53 \def\tkz@ptStar[#1](#2,#3)#{%
54 \pgfkeys{/tkzPt/.cd, polar = false}
55 \pgfqkeys{/tkzPt}{#1}
56 \iftkz@pt@polar%
57 \edef\tkz@x{\fpeval{#3*cosd(#2)}}
58 \edef\tkz@y{\fpeval{#3*sind(#2)}}
59 \else
60 \edef\tkz@x{\fpeval{#2}}
61 \edef\tkz@y{\fpeval{#3}}
62 \fi
63 \edef\tkzpt@xa{\tkz@Dec{(\tkz@x-(\tkz@init@xorigine))/\tkz@init@xstep}}
64 \edef\tkzpt@ya{\tkz@Dec{(\tkz@y-(\tkz@init@yorigine))/\tkz@init@ystep}}
65 \tkz@node
66 }
67 %<--------------------------------------------------------------------------->
68 % la macro defpoint les coordonnées cartésiennes ou polaires sont traitées
69 % afin de pouvoir être adaptées avec les unités choisies
70 %<--------------------------------------------------------------------------->
71 \def\tkzDefPoint{\pgfutil@ifnextchar[{\tkz@DefPoint}{\tkz@DefPoint[]}}
72
73 \def\tkz@DefPoint[#1](#2)#{%
74 \tkz@parsecoordinate{#2}
75 \iftkz@polar
76 \tkz@ptStar[polar](\tkz@polarangle,\tkz@polarrad){tkz@coord@temp}
77 \else
78 \tkz@ptStar[](#2){tkz@coord@temp}
79 \fi
80 \tkz@DefPointEnd[#1]
81 }%
82 \def\tkz@DefPointEnd[#1]#2{\coordinate[#1] (#2) at (tkz@coord@temp);}
83 %<--------------------------------------------------------------------------->
84 % tkzDefPoints
85 %<--------------------------------------------------------------------------->
86 \def\tkzDefPoints{\pgfutil@ifnextchar[{\tkz@DefPoints}{\tkz@DefPoints[]}}
87 \def\tkz@DefPoints[#1]#2{%
88 \begingroup
89 \def\tkz@parenthesis@for@err{(}%
90 \def\tkz@maybe@parenthesis{#2}%
91 \ifx\tkz@maybe@parenthesis\tkz@parenthesis@for@err
92 \PackageError{tkz-base}{Syntax error use {} instead of ()}{You need to use {} instead of ()}%
93 \expandafter\@firstoftwo
94 \else
95 \expandafter\@secondoftwo
96 \fi
97 {\tkz@absorb@bad@arg}%
98 {\foreach \ptx/\pty/\name in {#2}{\tkzDefPoint[#1](\ptx,\pty){\name}}%
99 \endgroup}%
100 }
101 \def\tkz@absorb@bad@arg#1){\endgroup}
102 %<--------------------------------------------------------------------------->
103 \def\tkz@node#1{ \pgfinterruptboundingbox
104 \path[coordinate](\tkzpt@xa,\tkzpt@ya) coordinate(#1);
105 \endpgfinterruptboundingbox}
106 %<--------------------------------------------------------------------------->
107 \def\tkzRenamePoint(#1)#2{\coordinate (#2) at (#1);}
108 \def\tkz@RenamePointEnd[#1]#2{\coordinate[#1] (#2) at (\tkz@ax,\tkz@ay);}
109 \def\tkzGetPoint#1{\coordinate (#1) at (tkzPointResult);}
110 \def\tkzGetPoints#1#2{\coordinate (#1) at (tkzFirstPointResult);
111 \coordinate (#2) at (tkzSecondPointResult);}
112 \def\tkzGetFirstPoint#1{\coordinate (#1) at (tkzFirstPointResult);}
113 \def\tkzGetSecondPoint#1{\coordinate (#1) at (tkzSecondPointResult);}
114 \def\tkzGetThirdPoint#1{\coordinate (#1) at (tkzThirdPointResult);}
115 \def\tkzDefShiftPointCoord[#1](#2)#3{%
116 \begin{scope}[shift={(#1)}]
117 \coordinate (#3) at (#2);
118 \end{scope}
119 }%
120 %<--------------------------------------------------------------------------–>
121 %<--------------------------------------------------------------------------->
122 % tkzDefShiftPoint
123 %<--------------------------------------------------------------------------->
124 \def\tkzDefShiftPoint[#1](#2)#3{%
125 \tkz@@extractxy{#1}
126 \tkz@ax\pgf@x %
127 \tkz@ay\pgf@y %
128 \begin{scope}[shift={(\tkz@ax,\tkz@ay)}]
129 \coordinate (#3) at (#2);
130 \end{scope}
131 }
132 %<--------------------------------------------------------------------------->
133 % Coordonnées d'un point
134 % result in #2x et #2y #1 est le point et on récupère ses coordonnées
135 % usage soit A un point \tkzGetPointCoord(A){V} alors \Vx = xA et \Vy = yA
136 % en cm
137 % tkzGetPointCoord avec [#1] cm ou bien pt ?? todo
138 %<--------------------------------------------------------------------------->
139 \def\tkzGetPointCoord(#1)#2{%
140 \begingroup
141 \pgfextractx{\pgf@x}{\pgfpointanchor{#1}{center}}
142 \pgfmathparse{\pgf@sys@tonumber{\pgf@x}/28.45274}
143 \global\let\tkzresultx\pgfmathresult
144 \global\expandafter\edef\csname #2x\endcsname{\tkzresultx}%
145 \pgfextracty{\pgf@y}{\pgfpointanchor{#1}{center}}
146 \pgfmathparse{\pgf@sys@tonumber{\pgf@y}/28.45274}
147 \global\let\tkzresulty\pgfmathresult
148 \global\expandafter\edef\csname #2y\endcsname{\tkzresulty}
149 \endgroup
150 }
151 \def\tkz@@extractxy#1{%
152 \pgfextractx{\pgf@x}{\pgfpointanchor{#1}{center}}
153 \pgfextracty{\pgf@y}{\pgfpointanchor{#1}{center}}
154 }
155 \let\tkzGetPointxy\tkzGetPointCoord
156 \makeatother
157 \endinput