summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tkz/tkz-base/doc/latex/TKZdoc-base-tools.tex
blob: 6a92b89bf2bcc99d891d814ac66138550b015271 (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
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
\section{Outils divers}

\subsection{Dupliquer un segment} 

Il s'agit de construire un segment sur une demi-droite donnée  de même longueur qu'un segment donné.

\begin{NewMacroBox}{tkzDuplicateSegment}{\parg{pt1,pt2}\parg{pt3,pt4}\marg{pt5}}
Il s'agit de créer un segment  sur une demi-droite  donnée de même longueur qu'un segment donné . Il s'agit en fait de la définition d'un point.

\medskip
  
\begin{tabular}{lll}
\toprule
arguments             & exemple & explication                         \\ 
\midrule
\TAline{(pt1,pt2)(pt3,pt4)\{pt5\}} {\tkzcname{tkzDuplicateLen}(A,B)(E,F)\{C\}}{AC=EF et $C \in [AB)$} \\                                                                         
\bottomrule
\end{tabular}

\medskip
La macro \tkzcname{tkzDuplicateLength} est identique à celle-ci. 
\end{NewMacroBox}

\begin{tkzexample}[latex=6cm,small]
   \begin{tikzpicture}
   \tkzDefPoint(0,0){A}
   \tkzDefPoint(2,-3){B}
   \tkzDefPoint(2,5){C} 
   \tkzDrawSegments[red](A,B A,C)
   \tkzDuplicateSegment(A,B)(A,C)  \tkzGetPoint{D}
   \tkzDrawSegment[green](A,D)
   \tkzDrawPoints[color=red](A,B,C,D) 
   \tkzLabelPoints[above right=3pt](A,B,C,D)
 \end{tikzpicture} 
\end{tkzexample} 

\subsubsection{Proportion d'or avec \tkzcname{tkzDuplicateSegment}} 

 \begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}[rotate=-90,scale=.75]
 \tkzInit[xmax=10,ymax=10]
 \tkzClip[space=1]
 \tkzDefPoint(0,0){A}
 \tkzDefPoint(10,0){B}
 \tkzDefMidPoint(A,B)   \tkzGetPoint{I}
 \tkzDefPointWith[orthogonal,K=-.75](B,A)
    \tkzGetPoint{C}
 \tkzInterLC(B,C)(B,I)  \tkzGetSecondPoint{D}
 \tkzDuplicateSegment(B,D)(D,A) \tkzGetPoint{E}
 \tkzInterLC(A,B)(A,E)   \tkzGetPoints{N}{M}
 \tkzDrawArc[delta=10](D,E)(B)
 \tkzDrawArc[delta=10](A,M)(E)
 \tkzDrawLines(A,B B,C A,D)
 \tkzDrawArc[delta=10](B,D)(I)
 \tkzDrawPoints(A,B,D,C,M,I,N)
 \tkzLabelPoints(A,B,D,C,M,I,N)
\end{tikzpicture}
 \end{tkzexample}
% <-------------------------------------------------------------------->
 %                About Angles
% <-------------------------------------------------------------------->
 \subsection{Déterminer une pente}
Il s'agit de déterminer si elle existe, la pente d'une droite définie par deux points. Aucune vérification de l'existence n'est faite.

\begin{NewMacroBox}{tkzFindSlope}{\parg{pt1,pt2}\marg{name of macro}}
Le résultat est stocké dans une macro.

\medskip

\begin{tabular}{lll}
\toprule
arguments             & exemple & explication                         \\
\midrule
\TAline{(pt1,pt2){pt3}} {\tkzcname{tkzFindSlope}(A,B)\{slope\}}{\tkzcname{slope} donnera le résultat de $\frac{y_B-y_A}{x_B-x_A}$} \\
\bottomrule
\end{tabular}

\medskip
\tkzHandBomb\ Attention à ne pas avoir $x_B=x_A$ 
\end{NewMacroBox}


\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}[scale=1.5]
  \tkzInit[xmax=4,ymax=5]\tkzGrid[sub]
  \tkzDefPoint(1,2){A}    \tkzDefPoint(3,4){B}
  \tkzDefPoint(3,2){C}    \tkzDefPoint(3,1){D}
  \tkzDrawSegments(A,B A,C A,D)
  \tkzDrawPoints[color=red](A,B,C,D)  
  \tkzLabelPoints(A,B,C,D)
  \tkzFindSlope(A,B){SAB} \tkzFindSlope(A,C){SAC}
  \tkzFindSlope(A,D){SAD}
  \pgfkeys{/pgf/number format/.cd,fixed,precision=2}
  \tkzText[fill=Gold!50,draw=brown](1,4)%
  {La pente de (AB) est : $\pgfmathprintnumber{\SAB}$}     
  \tkzText[fill=Gold!50,draw=brown](1,3.5)%
  {La pente de (AC) est : $\pgfmathprintnumber{\SAC}$}    
  \tkzText[fill=Gold!50,draw=brown](1,3)%
  {La pente de (AD) est : $\pgfmathprintnumber{\SAD}$}
\end{tikzpicture}
\end{tkzexample}

\subsection{Angle formé par une droite avec l'axe horizontal}
Beaucoup plus intéressante que la précédente. Le résultat est compris entre -180 degrés et +180 degrés.

\begin{NewMacroBox}{tkzFindSlopeAngle}{\parg{pt1,pt2}}
Le résultat est stocké dans une macro \tkzcname{tkzAngleResult}.

\medskip

\begin{tabular}{lll}
\toprule
arguments             & exemple & explication                         \\
\midrule
\TAline{(pt1,pt2)} {\tkzcname{tkzFindSlopeAngle}(A,B)}{\tkzcname{tkzGetAngle} peut récupèrer le résultat}
\bottomrule
\end{tabular}

\medskip
{Si la récupération n'est pas nécessaire, il est possible d'utiliser \tkzcname{tkzAngleResult}}
\end{NewMacroBox}


\subsubsection{Exemple d'utilisation de \tkzcname{tkzFindSlopeAngle}}
Voici une autre version de la construction d'une médiatrice

\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}
 \tkzInit
 \tkzDefPoint(0,0){A}        \tkzDefPoint(3,2){B}
 \tkzDefLine[mediator](A,B)  \tkzGetPoints{I}{J}
 \tkzCalcLength[cm](A,B)     \tkzGetLength{dAB}
 \tkzFindSlopeAngle(A,B)     \tkzGetAngle{tkzangle}
 \begin{scope}[rotate=\tkzangle]
   \tikzset{arc/.style={color=gray,delta=10}}
   \tkzDrawArc[R,arc](B,3/4*\dAB)(120,240)
   \tkzDrawArc[R,arc](A,3/4*\dAB)(-45,60)
   \tkzDrawLine(I,J)         \tkzDrawSegment(A,B)
  \end{scope}
  \tkzDrawPoints(A,B,I,J)    \tkzLabelPoints(A,B)
   \tkzLabelPoints[right](I,J)
\end{tikzpicture}
\end{tkzexample}

\subsection{Récupérer un angle}
Dans l'exemple précédent, j'ai utilisé la macro  \tkzcname{tkzGetAngle} qui permet de récupérer un angle.

\begin{NewMacroBox}{tkzGetAngle}{\marg{name of macro}}
Cette macro récupère  \tkzcname{tkzAngleResult} et stocke le résultat dans une nouvelle macro.

\medskip

\begin{tabular}{lll}
\toprule
arguments             & exemple & explication                         \\
\midrule
\TAline{name of macro} {\tkzcname{tkzGetAngle}\{ang\}}{\tkzcname{ang} contient la valeur de l'angle.}
\end{tabular}
\end{NewMacroBox}

\subsection{Exemple d'utilisation de \tkzcname{tkzGetAngle}}

 Il s'agit ici que $(AB)$ soit la bissectrice de $\widehat{CAD}$, tel que la pente $AD$ soit nulle. On récupère la pente de $(AB)$ puis on effectue deux rotations.


\begin{tkzexample}[vbox,small]
\begin{tikzpicture}
  \tkzInit
  \tkzDefPoint(1,5){A} \tkzDefPoint(5,2){B}  
  \tkzDrawSegment(A,B)
  \tkzFindSlopeAngle(A,B)\tkzGetAngle{tkzang}
  \tkzDefPointBy[rotation= center A angle \tkzang ](B)
   \tkzGetPoint{C}
  \tkzDefPointBy[rotation= center A angle -\tkzang ](B) 
  \tkzGetPoint{D}
  \tkzCompass[length=1,dashed,color=red](A,C)
  \tkzCompass[delta=10,brown](B,C)  
   \tkzDrawPoints(A,B,C,D)
  \tkzLabelPoints(B,C,D)  
  \tkzLabelPoints[above left](A)
  \tkzDrawSegments[style=dashed,color=orange!30](A,C A,D)
\end{tikzpicture}
\end{tkzexample}

\subsection{Angle formé par trois points}


\begin{NewMacroBox}{tkzFindAngle}{\parg{pt1,pt2,pt3}}
Le résultat est stocké dans une macro \tkzcname{tkzAngleResult}.

\medskip

\begin{tabular}{lll}
\toprule
arguments             & exemple & explication                         \\
\midrule
\TAline{(pt1,pt2,pt3)} {\tkzcname{tkzFindAngle}(A,B,C)}{\tkzcname{tkzAngleResult} donne l'angle ($\overrightarrow{BA},\overrightarrow{BC}$)}
\bottomrule
\end{tabular}

\medskip
Le résultat est compris entre -180 degrés et +180 degrés. pt2 est le sommet et  \tkzcname{tkzGetAngle} peut récupérer l'angle.
\end{NewMacroBox}

\subsection{Exemple d'utilisation de \tkzcname{tkzFindAngle} }

\begin{tkzexample}[vbox,small]
\begin{tikzpicture}
   \tkzInit[xmin=-1,ymin=-1,xmax=7,ymax=7]
   \tkzClip  
   \tkzDefPoint (0,0){O}  \tkzDefPoint (6,0){A}
   \tkzDefPoint (5,5){B}  \tkzDefPoint (3,4){M}
   \tkzFindAngle (A,O,M)  \tkzGetAngle{an}   
   \tkzDefPointBy[rotation=center O angle \an](A) 
   \tkzGetPoint{C}
   \tkzDrawSector[fill = blue!50,opacity=.5](O,A)(C)
   \tkzFindAngle(M,B,A)   \tkzGetAngle{am}
   \tkzDefPointBy[rotation = center O angle \am](A) 
   \tkzGetPoint{D} 
   \tkzDrawSector[fill = red!50,opacity = .5](O,A)(D) 
   \tkzDrawPoints(O,A,B,M,C,D)   
   \tkzLabelPoints(O,A,B,M,C,D) 
	\edef\an{\fpeval{round(\an,2)}}\edef\am{\fpeval{round(\am,2)}}
   \tkzDrawSegments(M,B B,A)
   \tkzText(4,2){$\widehat{AOC}=\widehat{AOM}=\an^{\circ}$} 
   \tkzText(1,4){$\widehat{AOD}=\widehat{MBA}=\am^{\circ}$}  
\end{tikzpicture}
\end{tkzexample}

\subsection{Longueur d'un segment \tkzcname{tkzCalcLength}}
Il existe dans \TIKZ\ une option \tkzname{veclen}. Cette option
 permet de calculer AB si A et B sont deux points.

Le seul problème pour moi est que la version de \TIKZ\ n'est pas assez précise dans certains cas particuliers. Ma version utilise le package \tkzNamePack{xfp} et est plus lente, mais plus précise

\begin{NewMacroBox}{tkzCalcLength}{\oarg{local options}\parg{pt1,pt2}\marg{name of macro}}
Le résultat est stocké dans une macro.

\medskip
\begin{tabular}{lll}
\toprule
arguments             & exemple & explication                         \\
\midrule
\TAline{(pt1,pt2)\{name of macro\}} {\tkzcname{tkzCalcLength}(A,B)\{dAB\}}{\tkzcname{dAB} donne  $AB$ en pt}
\bottomrule
\end{tabular}

\medskip

Une seule option

\begin{tabular}{lll}
   
\toprule
 options             & défaut & exemple                         \\
\midrule
\TOline{cm}  {false}{\tkzcname{tkzCalcLength}[cm](A,B)\{dAB\} \tkzcname{dAB} donne AB en cm}
\end{tabular}
\end{NewMacroBox}

\subsubsection{Construction d'un carré au compas}

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}[scale=1]
  \tkzDefPoint(0,0){A} \tkzDefPoint(4,0){B}
  \tkzDrawLine[add= .6 and .2](A,B)
  \tkzCalcLength[cm](A,B)\tkzGetLength{dAB}
  \tkzDefLine[perpendicular=through A](A,B)
  \tkzDrawLine(A,tkzPointResult) \tkzGetPoint{D}
  \tkzShowLine[orthogonal=through A,gap=2](A,B)
  \tkzMarkRightAngle(B,A,D)
  \tkzVecKOrth[-1](B,A)\tkzGetPoint{C}
  \tkzCompasss(A,D D,C)
  \tkzDrawArc[R](B,\dAB)(80,110)
  \tkzDrawPoints(A,B,C,D)
  \tkzDrawSegments[color=gray,style=dashed](B,C C,D)
  \tkzLabelPoints(A,B,C,D)
\end{tikzpicture}
\end{tkzexample}

\subsection{Transformation de pt en cm ou de cm en pt}
Pas sûr que cela soit nécessaire et il ne s'agit que d'une division par 28,45274 et d'un multiplication par ce même nombre. Les macros sont :

\begin{NewMacroBox}{tkzpttocm}{\parg{nombre}\marg{name of macro}}
Le résultat est stocké dans une macro.

\medskip

\begin{tabular}{lll}
\toprule
arguments             & exemple & explication                         \\
\midrule
\TAline{(nombre){name of macro}} {\tkzcname{tkzpttocm}(120)\{len\}}{\tkzcname{len} donne un nombre de tkzname{cm}}
\bottomrule
\end{tabular}

\medskip
Il faudra utiliser \tkzcname{len} accompagné de \tkzname{cm}
\end{NewMacroBox}

\subsection{changement d'unité} 
\begin{NewMacroBox}{tkzcmtopt}{\parg{nombre}\marg{name of macro}}
Le résultat est stocké dans une macro.

\medskip

\begin{tabular}{lll}
\toprule
arguments             & exemple & explication                         \\
\midrule
\TAline{(nombre)\{name of macro\}}{\tkzcname{tkzcmtopt}(5)\{len\}}{\tkzcname{len} longueur en \tkzname{pts}}
\bottomrule
\end{tabular}

\medskip
\noindent{Le résultat s'utilise avec \tkzcname{len}\tkzname{pt}}
\end{NewMacroBox}

\subsubsection{Exemple}
La macro    \tkzcname{tkzDefCircle[radius](A,B)} définit le rayon que l'on récupère avec     \tkzcname{tkzGetLength}, mais ce résultat est en \tkzname{pt}.

\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}[scale=.5]
   \tkzDefPoint(0,0){A}
   \tkzDefPoint(3,-4){B}
   \tkzDefCircle[through](A,B)
   \tkzGetLength{rABpt}
   \tkzpttocm(\rABpt){rABcm}
   \tkzDrawCircle(A,B)
   \tkzDrawPoints(A,B)
   \tkzLabelPoints(A,B)
   \tkzDrawSegment[dashed](A,B)
   \tkzLabelSegment(A,B){%
       $\pgfmathprintnumber{\rABcm}$}
\end{tikzpicture}
\end{tkzexample}

%<--------------------------------------------------------------------------–>
%                    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
%<--------------------------------------------------------------------------–>
\begin{NewMacroBox}{tkzGetPointCoord}{\parg{$A$}\marg{name of macro}}
Stocke dans deux macros les coordonnées d'un point

\medskip
\begin{tabular}{lll}
\toprule
arguments             & exemple & explication                         \\
\midrule
\TAline{(point)\{name of macro\}} {\tkzcname{tkzGetPointCoord}(A)\{A\}}{\tkzcname{Ax} et \tkzcname{Ay} donnent les coordonnées de $A$}

\end{tabular}

\medskip
Si le nom de la macro est \tkzname{p}, alors \tkzcname{px} et \tkzcname{py} donnent les coordonnées du point choisi avec le cm comme.
\end{NewMacroBox}

\subsubsection{Transfert de coordonnées avec \tkzcname{tkzGetPointCoord}}

\begin{tkzexample}[width=8cm,small]
\begin{tikzpicture}
 \tkzInit[xmax=5,ymax=3]
 \tkzGrid[sub,orange]
 \tkzAxeXY
 \tkzDefPoint(1,0){A}
 \tkzDefPoint(4,2){B}
 \tkzGetPointCoord(A){a}
 \tkzGetPointCoord(B){b}
 \tkzDefPoint(\ax,\ay){C}
 \tkzDefPoint(\bx,\by){D}
 \tkzDrawPoints[color=red](C,D)
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Somme de vecteurs avec \tkzcname{tkzGetPointCoord}}
\begin{tkzexample}[width=6cm,small]
\begin{tikzpicture}[>=latex]
   \tkzDefPoint(1,4){a}
   \tkzDefPoint(3,2){b}
   \tkzDefPoint(1,1){c}
   \tkzDrawSegment[->,red](a,b)
   \tkzGetPointCoord(c){c}
   \draw[color=blue,->](a) -- ([shift=(b)]\cx,\cy) ;
   \draw[color=purple,->](b) -- ([shift=(b)]\cx,\cy) ;
   \tkzDrawSegment[->,blue](a,c)
   \tkzDrawSegment[->,purple](b,c)
\end{tikzpicture}
\end{tkzexample}

\endinput