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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
% tkz-obj-lua-points-with.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-with.tex}
\makeatletter
%<--------------------------------------------------------------------------–>
% Vectors
%<--------------------------------------------------------------------------–>
% Objet : outils mathématiques pour la géométrie euclideienne avec pgf/tikz
% utilisable de préférence avec un repère orthonormé et le cm comme unité
% utile pour la compatibilité avec pgf 2
%<--------------------------------------------------------------------------–>
% Duplicate Length à revoir pas de pt pas de global
% ||v(CN)||= ||v(AB)|| et v(CN) colineaire à v(CD)
% A-->#1 B-->#2 C-->#3 D-->#4 N-->#5 ?????
%<--------------------------------------------------------------------------–>
%<--------------------------------------------------------------------------–>
% Outils pour les vecteurs
%<--------------------------------------------------------------------------–>
% ce sont des outils élémentaires qui à partir de deux points en définissent
% un troisième
% #1 si c'est une option alors c'est un nombre réel
% #2 et #3 sont deux points
% #4 est le nom du point qui résulte de la transformation
% exemple : \tkzVecKNorm (A,B){C} définit un point C tel que AC = 1 et C est % % un point de la droite (AC). #1 peut être négatif
\def\tkzDuplicateSegment(#1,#2)(#3,#4){%
\begingroup
\tkz@@CalcLength(#1,#2){tkz@firstlen}%
\tkz@@CalcLength(#3,#4){tkz@secondlen}%
\edef\tkz@ratio{\tkz@Dec{\tkz@firstlen/\tkz@secondlen}}
\tkz@VecKCoLinear[\tkz@ratio](#3,#4,#3)%
\endgroup
}
\let\tkzDuplicateLength\tkzDuplicateSegment
%<--------------------------------------------------------------------------–>
% Coordonnées d'un vecteur (couple de points)
% Deux points A et B donc un vecteur on récupère les coordonnées de v(AB)
% en cm
% tkzGetVecCoord en cm ou en pt ???
%<--------------------------------------------------------------------------–>
%result in #3x et #3y #1 et #2 sont les points
% passage en cm avec fp ?
% 28.45274 =1 cm
\def\tkzGetVectxy(#1,#2)#3{%
\begingroup
\pgfpointdiff{\pgfpointanchor{#1}{center}}%
{\pgfpointanchor{#2}{center}}%
\pgfmathparse{\pgf@sys@tonumber{\pgf@x}/1cm}%
\let\tkzresultx\pgfmathresult
\pgfmathparse{\pgf@sys@tonumber{\pgf@y}/1cm}%
\let\tkzresulty\pgfmathresult
\global\expandafter\edef\csname #3x\endcsname{\tkzresultx}%
\global\expandafter\edef\csname #3y\endcsname{\tkzresulty}%
\endgroup
}
%<--------------------------------------------------------------------------–>
% options #1 two points #2,#3 result in #4
%
%<--------------------------------------------------------------------------–>
%<--------------------------------------------------------------------------–>
% tkzDefPointWith
%<--------------------------------------------------------------------------–>
\def\tkz@numv{0}
\pgfkeys{/@pointwith/.cd,
colinear/.code args = {at #1}{\def\tkz@numv{0}\def\tkz@frompoint{#1}},
orthogonal/.code = {\def\tkz@numv{1}},
linear/.code = {\def\tkz@numv{2}},
orthogonal normed/.code = {\def\tkz@numv{3}},
linear normed/.code = {\def\tkz@numv{4}},
colinear normed/.code args = {at #1}{\def\tkz@numv{5}\def\tkz@frompoint{#1}},
K/.code = {\edef\tkz@coeff{\fpeval{#1}}},
K = 1,
normed/.is if = tkz@line@normed,
normed/.default = true,
normed = false,
orthogonal
}
\def\tkzDefPointWith{\pgfutil@ifnextchar[{\tkz@DefPointWith}{\tkz@DefPointWith[]}}
\def\tkz@DefPointWith[#1](#2,#3){%
\begingroup
\pgfkeys{/@pointwith/.cd,K=1}
\pgfqkeys{/@pointwith}{#1}
\ifcase\tkz@numv%
% first case 0
\tkz@DefVectorColinearat[\tkz@coeff](#2,#3)
\or% 1
\tkz@VecKOrth[\tkz@coeff](#2,#3)
\or% 2
\tkz@VecK[\tkz@coeff](#2,#3)
\or% 3
\tkz@VecKOrthNorm[\tkz@coeff](#2,#3)
\or% 4
\tkz@VecKNorm[\tkz@coeff](#2,#3)
\or% 5
\tkz@VecKColinearNorm[\tkz@coeff](#2,#3)
\fi
\endgroup
}
%<--------------------------------------------------------------------------–>
% tkzDefVectorfrom
%<--------------------------------------------------------------------------–>
% tkz@numv 0
\def\tkz@DefVectorColinearat[#1](#2,#3){%
\iftkz@line@normed
\tkz@VecKColinearNorm[#1](#2,#3)
\else
\begingroup
\pgfpointdiff{\pgfpointanchor{#2}{center}}{\pgfpointanchor{#3}{center}}%
\pgf@xa=\pgf@x\relax%
\pgf@ya=\pgf@y\relax%
\pgfinterruptboundingbox
\path (\tkz@frompoint)--++(\tkz@coeff\pgf@xa,\tkz@coeff\pgf@ya) coordinate (tkzPointResult);
\endpgfinterruptboundingbox
\endgroup
\fi
}
%<--------------------------------------------------------------------------–>
% tkzVector K Orth coeff dans #1
% v(AN) perp v(AB) (v(AB) , v(AN) ) sens direct cercle trigo
% ||v(AN)||=||v(AB)||
%<--------------------------------------------------------------------------–>
% tkz@numv 1
\def\tkzVecKOrth{\pgfutil@ifnextchar[{\tkz@VecKOrth}{\tkz@VecKOrth[1]}}
\def\tkz@VecKOrth[#1](#2,#3){%
\iftkz@line@normed
\tkz@VecKOrthNorm[#1](#2,#3)
\else
\begingroup
\pgfpointdiff{\pgfpointanchor{#2}{center}}{\pgfpointanchor{#3}{center}}%
\pgf@xa=-\pgf@y%
\pgf@ya=\pgf@x%
\pgfinterruptboundingbox
\path (#2)--++(\tkz@coeff\pgf@xa,\tkz@coeff\pgf@ya) coordinate (tkzPointResult);
\endpgfinterruptboundingbox
\endgroup
\fi
}%
%<--------------------------------------------------------------------------–>
% v(AN)=#1 x v(AB)
% #1 le coeff; #2--> A #3--> B #4-->N tq #4-#2 = #1*(#3-#2)
%<--------------------------------------------------------------------------–>
% tkz@numv 2
\def\tkzVecK{\pgfutil@ifnextchar[{\tkz@VecK}{\tkz@VecK[1]}}
\def\tkz@VecK[#1](#2,#3){%
\iftkz@line@normed
\tkz@VecKNorm[#1](#2,#3)
\else
\begingroup
\pgfpointdiff{\pgfpointanchor{#2}{center}}%
{\pgfpointanchor{#3}{center}}%
\pgf@xa=\pgf@x\relax%
\pgf@ya=\pgf@y\relax%
\pgfmathparse{#1}
\let\tkz@coeff\pgfmathresult
\pgfinterruptboundingbox
\path (#2)--++(\tkz@coeff\pgf@xa,\tkz@coeff\pgf@ya) coordinate (tkzPointResult);
\endpgfinterruptboundingbox
\endgroup
\fi
}%
%<--------------------------------------------------------------------------–>
% tkzVecKOrthNorm coeff dans #1
% v(AN) perp v(AB) v(AB) v(AN) sens direct cercle trigo
% ||v(AN||=1 si #1 est vide ou =1 sinon ||v(AN||=K
%<--------------------------------------------------------------------------–>
% tkz@numv 3
\def\tkzVecKOrthNorm{\pgfutil@ifnextchar[{\tkz@VecKOrthNorm}%
{\tkz@VecKOrthNorm[1]}}
\def\tkz@VecKOrthNorm[#1](#2,#3){%
\begingroup
\tkzpointnormalised{\pgfpointdiff{\pgfpointanchor{#2}{center}}%
{\pgfpointanchor{#3}{center}}}
\pgf@xa=-\pgf@y\relax%
\pgf@ya=\pgf@x\relax%
\pgfmathparse{#1}
\let\tkz@tmp\pgfmathresult
\edef\tkz@x{\tkz@Dec{28.45274*\tkz@tmp*\strip@pt\pgf@xa}}
\edef\tkz@y{\tkz@Dec{28.45274*\tkz@tmp*\strip@pt\pgf@ya}}
\pgfinterruptboundingbox
\path (#2)--++(\tkz@x pt,\tkz@y pt) coordinate (tkzPointResult);
\endpgfinterruptboundingbox
\endgroup
}%
%<--------------------------------------------------------------------------–>
% VectorNormalised ou K*VectorNormalised
% A-->#2 B-->#3 N-->#4 v(AB) devient v(AN) tq ||v(AN)||=1 si #1=1
% sinon ||v(AN)||=#1
%<--------------------------------------------------------------------------–>
% tkz@numv 4
\def\tkzVecKNorm{\pgfutil@ifnextchar[{\tkz@VecKNorm}{\tkz@VecKNorm[1]}}
\def\tkz@VecKNorm[#1](#2,#3){%
\begingroup
\tkzpointnormalised{%
\pgfpointdiff{\pgfpointanchor{#2}{center}}
{\pgfpointanchor{#3}{center}}}
\pgf@xa=\pgf@x\relax%
\pgf@ya=\pgf@y\relax%
\pgfmathparse{#1}
\let\tkz@tmp\pgfmathresult
\edef\tkz@x{\tkz@Dec{28.45274*\tkz@tmp*\strip@pt\pgf@xa}}
\edef\tkz@y{\tkz@Dec{28.45274*\tkz@tmp*\strip@pt\pgf@ya}}
\pgfinterruptboundingbox
\path (#2)--++(\tkz@x pt,\tkz@y pt) coordinate (tkzPointResult);
\endpgfinterruptboundingbox
\endgroup
}%
%<--------------------------------------------------------------------------–>
% \tkz@VecKColinearNorm
%<--------------------------------------------------------------------------–>
%% tkz@numv 5
\def\tkz@VecKColinearNorm[#1](#2,#3){%
\begingroup
\tkzpointnormalised{%
\pgfpointdiff{\pgfpointanchor{#2}{center}}
{\pgfpointanchor{#3}{center}}}
\pgf@xa=\pgf@x\relax%
\pgf@ya=\pgf@y\relax%
\edef\tkz@x{\tkz@Dec{28.45274*(\tkz@coeff)*\strip@pt\pgf@xa}}
\edef\tkz@y{\tkz@Dec{28.45274*(\tkz@coeff)*\strip@pt\pgf@ya}}
\pgfinterruptboundingbox
\path (\tkz@frompoint)--++(\tkz@x pt,\tkz@y pt) coordinate (tkzPointResult);
\endpgfinterruptboundingbox
\endgroup
}%
%<--------------------------------------------------------------------------–>
% VecKCoLinear CN = K x AB #1 pt #2 pt #3 pt #4 nb #5 pt result
% il faut modifier cette macro : on supprime #3 pour la colinéarité
% Il suffit d'utiliser Replicate ou Duplicate coeff dans #1
% v(CD)=#1 x v(AB) #1 le coeff; #2-->A #3-->B #4-->C
%<--------------------------------------------------------------------------–>
\def\tkz@VecKCoLinear[#1](#2,#3,#4){%
\begingroup
\pgfpointdiff{\pgfpointanchor{#2}{center}}%
{\pgfpointanchor{#3}{center}}%
\pgf@xa=\pgf@x\relax%
\pgf@ya=\pgf@y\relax%
\edef\tkz@coeff{\fpeval{#1}}
\pgfinterruptboundingbox
\path (#4)--+(\tkz@coeff\pgf@xa,\tkz@coeff\pgf@ya) coordinate (tkzPointResult);
\endpgfinterruptboundingbox
\endgroup
}%
\def\tkz@VecCoLinear(#1,#2,#3){%
\begingroup
\pgfpointdiff{\pgfpointanchor{#1}{center}}%
{\pgfpointanchor{#2}{center}}%
\pgf@xa=\pgf@x\relax%
\pgf@ya=\pgf@y\relax%
\pgfinterruptboundingbox
\path (#3)--+(\pgf@xa,\pgf@ya) coordinate (tkzPointResult);
\endpgfinterruptboundingbox
\endgroup
}%
\makeatother
\endinput
|