summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-classes-misc.tex
blob: d0867da26942f4e2f4013ec9c3b4183f1b9f5448 (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
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
\clearpage\newpage
 \section{Math constants and functions} % (fold)
 \label{sec:math_functions}

\bgroup
\catcode`_=12 
\small
\captionof{table}{Math constants and functions.}\label{misc}
\begin{tabular}{ll}
\toprule
\textbf{contants or functions} & \textbf{Comments}\\
\midrule
\Igfct{math}{tkzphi}     &  constant $\varphi  = (1+math.sqrt(5))/2 $\\
\Igfct{math}{tkzinvphi}   &  constant $1/\varphi  = 1/tkzphi$\\
\Igfct{math}{tkzsqrtphi}    &  constant $\sqrt{\varphi}= math.sqrt(tkzphi)$    \\
%round(num, idp)    &  \\
%tkzround( num, idp )   &   \\
% Cramer33(a1,a2,a3,b1,b2,b3,c1,c2,c3) &  \\
% Cramer22(a1,a2,b1,b2)  &   \\
\Igfct{math}{length (a,b) }     &  point.abs(a-b) See (\ref{ssub:report_de_distance})   \\
\Igfct{math}{islinear (z1,z2,z3) }   & Are the points aligned? (z2-z1) $\parallel$ (z3-z1) ?  \\
\Igfct{math}{isortho (z1,z2,z3)} &  (z2-z1) $\perp$ (z3-z1)  ? boolean\\
\Igfct{math}{get\_angle (z1,z2,z3)} & the vertex is z1 See (\ref{sub:get_angle}) \\
\Igfct{math}{bisector (z1,z2,z3)} & L.Aa = bisector (z.A,z.B,z.C) from A (\ref{sub:get_angle})\\
\Igfct{math}{bisector\_ext (z1,z2,z3)} & L.Aa = bisector_ext (z.A,z.B,z.C) from A \\
\Igfct{math}{altitude (z1,z2,z3)} & altitude from z1 \\
\Igfct{package}{set\_lua\_to\_tex (list)}   & set\_lua\_to\_tex('a','n') defines |\a| and |\n|   \\
\Igfct{package}{tkzUseLua (variable)}   & |\textbackslash\tkzUseLua{a}| prints  the value of a\\
%parabola (a,b,c)   & to get   \\
\Igfct{math}{value (v) }     &  apply |scale * value |    \\
\Igfct{math}{real (v) }     &  apply  | value /scale |     \\
\Igfct{math}{angle\_normalize (an) }   &  to get a value between 0 and $2\pi$ \\
\Igfct{misc}{barycenter (\{z1,n1\},\{z2,n2\}, ...)} & barycenter of list of points  \\
\bottomrule
\end{tabular}
\egroup

\subsection{Length of a segment} % (fold)
\label{sub:length_of_a_segment}
|length(z.A,z.B)| is a shortcut for |point.abs(z.A-z.B)|. This avoids the need to use complexes.

% subsection length_of_a_segment (end)


\subsection{Harmonic division with tkzphi } % (fold)
\label{sub:harmonic_division_with_tkzphi}
\begin{tkzexample}[latex=0cm,small,code only]
\begin{tkzelements}
   scale =.5
   z.a = point: new(0,0)
   z.b = point: new(8,0)
   L.ab = line: new (z.a,z.b)
   z.m,z.n = L.ab: harmonic_both (tkzphi)
\end{tkzelements}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawLine[add= .2 and .2](a,n) 
   \tkzDrawPoints(a,b,n,m)
   \tkzLabelPoints(a,b,n,m)
\end{tikzpicture}
\end{tkzexample}


\begin{tkzelements}
   scale =.5
   z.a = point: new(0,0)
   z.b = point: new(8,0)
   L.ab = line: new (z.a,z.b)
   z.m,z.n = L.ab: harmonic_both (tkzphi)
\end{tkzelements}
\hspace*{\fill}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawLine[add= .2 and .2](a,n) 
   \tkzDrawPoints(a,b,n,m)
   \tkzLabelPoints(a,b,n,m)
\end{tikzpicture}
 \hspace*{\fill}
% subsection harmonic_division_with_tkzphi (end)

\subsection{Function islinear} % (fold)
\label{sub:function_islinear}
\begin{minipage}{0.5\textwidth}
\begin{tkzexample}[latex=0cm,small,code only]
\begin{tkzelements}
   z.a = point: new (1, 1)
   z.b = point: new (2, 2)
   z.c = point: new (4, 4)
   if islinear (z.a,z.b,z.c) then
       z.d = point: new (0, 0)
    else 
        z.d = point: new (-1, -1)
   end
\end{tkzelements}
\begin{tikzpicture}
    \tkzGetNodes
    \tkzDrawPoints(a,...,d)
    \tkzLabelPoints(a,...,d)
\end{tikzpicture}
\end{tkzexample}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{tkzelements}
   z.a = point: new (1, 1)
   z.b = point: new (2, 2)
   z.c = point: new (4, 4)
   if islinear (z.a,z.b,z.c) then
       z.d = point: new (0, 0)
    else 
        z.d = point: new (-1, -1)
   end
\end{tkzelements}
 \hspace*{\fill}
\begin{tikzpicture}
    \tkzGetNodes
    \tkzDrawPoints(a,...,d)
    \tkzLabelPoints(a,...,d)
\end{tikzpicture}
\hspace*{\fill}
\end{minipage}

% subsection function_islinear (end)

\subsection{Function  value }% (fold)
\label{sub:function_value}

value to apply scaling if necessary

If |scale = 1.2| with a = value(5) the actual value of |a| will be $5\times 1.2 = 6$.

% subsubsection function_value (end)

\subsubsection{Function  real }% (fold)
\label{ssub:function_real}

If |scale = 1.2| with a = 6 then real(a) = $6 / 1.2 = 5$ .

% subsection function_real (end)


\subsection{Transfer from lua to \TEX} % (fold)
\label{sub:transfer_from_lua_to_tex}
It's possible to transfer variable from Lua to \TEX{} with 
\Igfct{package}{\textbackslash{tkzUseLua}}.


\begin{minipage}{.5\textwidth}
\begin{verbatim}
\begin{tkzelements}
   z.A            = point : new (0 , 0)
   z.B            = point : new (3 , 2)
   z.C            = point : new (2 , 5)
   L.AB           = line : new (z.A,z.B)
   d              = L.AB : distance (z.C)
   l              = L.AB.length
   z.H            = L.AB : projection (z.C)
\end{tkzelements}
\begin{tikzpicture}
\tkzGetNodes
\tkzDrawLines(A,B C,H)
\tkzDrawPoints(A,B,C,H)
\tkzLabelPoints(A,B,C,H)
\tkzLabelSegment[above right,draw](C,H){$CH = \tkzUseLua{d}$}
\tkzLabelSegment[below right,draw](A,B){$AB = \tkzUseLua{l}$}
\end{tikzpicture}
\end{verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\begin{tkzelements}
   z.A            = point : new (0 , 0)
   z.B            = point : new (3 , 2)
   z.C            = point : new (2 , 5)
   L.AB           = line : new (z.A,z.B)
   d              = L.AB : distance (z.C)
   l              = L.AB.length
   z.H            = L.AB : projection (z.C)
\end{tkzelements}
 \hspace*{\fill}
\begin{tikzpicture}
\tkzGetNodes
\tkzDrawLines(A,B C,H)
\tkzDrawPoints(A,B,C,H)
\tkzLabelPoints(A,B,C,H)
\tkzLabelSegment[above right,draw](C,H){$CH = \tkzUseLua{d}$}
\tkzLabelSegment[below right,draw](A,B){$AB = \tkzUseLua{l}$}
\end{tikzpicture}
\end{minipage}
% subsection transfer_from_lua_to_tex (end)

\subsection{Normalized angles : Slope of lines (ab), (ac) and (ad)} % (fold)
\label{sub:normalized_angles}
\begin{tkzexample}[latex=0cm,small,code only]
\begin{tkzelements}
   z.a      = point: new(0, 0)
   z.b      = point: new(-3, -3)
   z.c      = point: new(0, 3)
   z.d      = point: new(2, -2)
   angle    = point.arg (z.b-z.a)
   tex.print('slope of (ab) : '..tostring(angle)..'\\\\')
   tex.print('slope normalized of (ab) : '..tostring(angle\_normalize(angle))..'\\\\')
   angle    = point.arg (z.c-z.a)
   tex.print('slope of (ac) : '..tostring(angle)..'\\\\')
   tex.print('slope normalized of (ac) : '..tostring(angle\_normalize(angle))..'\\\\')
   angle    = point.arg (z.d-z.a)
   tex.print('slope of (ad) : '..tostring(angle)..'\\\\')
   tex.print('slope normalized of (acd) : '..tostring(angle\_normalize(angle))..'\\\\')
\end{tkzelements}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawLines[red](a,b a,c a,d)
   \tkzDrawPoints(a,b,c,d)
   \tkzLabelPoints(a,b,c,d)
\end{tikzpicture}
\end{tkzexample}
\begin{tkzelements}
  scale = .75
z.a = point: new(0, 0)
z.b = point: new(-3, -3)
z.c = point: new(0, 3)
z.d = point: new(2, -2)
angle = point.arg (z.b-z.a)
tex.print('slope of (ab) : '..tostring(angle)..'\\\\')
tex.print('slope normalized of (ab) : '..tostring(angle_normalize(angle))..'\\\\')
angle = point.arg (z.c-z.a)
tex.print('slope of (ac) : '..tostring(angle)..'\\\\')
tex.print('slope normalized of (ac) : '..tostring(angle_normalize(angle))..'\\\\')
angle = point.arg (z.d-z.a)
tex.print('slope of (ad) : '..tostring(angle)..'\\\\')
tex.print('slope normalized of (ad) : '..tostring(angle_normalize(angle))..'\\\\')
\end{tkzelements}

  \hspace*{\fill}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawLines[red](a,b a,c a,d)
   \tkzDrawPoints(a,b,c,d)
   \tkzLabelPoints(a,b,c,d)
\end{tikzpicture}
 \hspace*{\fill}

% subsection normalized_angles (end)

\subsection{Get angle} % (fold)
\label{sub:get_angle}

The function  |get_angle (a,b,c)| gives the angle normalized of $(\overrightarrow{ab},\overrightarrow{ac})$.

\begin{minipage}{0.6\textwidth}
\begin{tkzexample}[latex=0cm,small,code only]
\begin{tkzelements}
   z.a   = point: new(0, 0)
   z.b   = point: new(-2, -2)
   z.c   = point: new(0, 3)
   angcb = tkzround ( get_angle (z.a,z.c,z.b),3)
   angbc = tkzround ( get_angle (z.a,z.b,z.c),3)
\end{tkzelements}

\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawLines[red](a,b a,c)
   \tkzDrawPoints(a,b,c)
   \tkzLabelPoints(a,b,c)
   \tkzMarkAngle[->](c,a,b)
   \tkzLabelAngle(c,a,b){\tkzUseLua{angcb}}
   \tkzMarkAngle[->](b,a,c)
   \tkzLabelAngle(b,a,c){\tkzUseLua{angbc}}
\end{tikzpicture}
\end{tkzexample}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\begin{tkzelements}
   scale = 1.2
   z.a   = point: new(0, 0)
   z.b   = point: new(-2, -2)
   z.c   = point: new(0, 3)
   angcb = tkzround ( get_angle (z.a,z.c,z.b),3)
   angbc = tkzround ( get_angle (z.a,z.b,z.c),3)
\end{tkzelements}

\hspace*{\fill}
\begin{tikzpicture}
\tkzGetNodes
\tkzDrawLines[red](a,b a,c)
\tkzDrawPoints(a,b,c)
\tkzLabelPoints(a,b,c)
\tkzMarkAngle[->](c,a,b)
\tkzLabelAngle(c,a,b){\tkzUseLua{angcb}}
\tkzMarkAngle[->](b,a,c)
\tkzLabelAngle(b,a,c){\tkzUseLua{angbc}}
\end{tikzpicture}
\hspace*{\fill}
\end{minipage}
% subsection get_angle (end)

\subsection{Dot or scalar product} % (fold)
\label{sub:dot_or_scalar_product}

\begin{minipage}{0.5\textwidth}
\begin{tkzexample}[latex=0cm,small,code only]
\begin{tkzelements}
   z.A    = point: new(0,0)
   z.B    = point: new(5,0)
   z.C    = point: new(0,3)
   T.ABC  = triangle: new (z.A,z.B,z.C)
   z.A_1,
   z.B_1,
   z.C_1  = get_points (T.ABC: anti ())
   x  = dot_product (z.A,z.B,z.C)
\end{tkzelements}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPolygon(A,B,C)
   \tkzDrawPoints(A,B,C,A_1,B_1,C_1)
   \tkzLabelPoints(A,B,C,A_1,B_1,C_1)
   \tkzDrawPolygon[blue](A_1,B_1,C_1)
   \tkzText[right](0,-1){dot product =\tkzUseLua{x}}
\end{tikzpicture}
\end{tkzexample}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{tkzelements}
 scale  = .6
 z.A    = point: new(0,0)
 z.B    = point: new(5,0)
 z.C    = point: new(0,3)
 T.ABC  = triangle: new (z.A,z.B,z.C)
 z.A_1,
 z.B_1,
 z.C_1  = get_points (T.ABC: anti ())
 x  = dot_product (z.A,z.B,z.C)
\end{tkzelements}
\hspace*{\fill}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPolygon(A,B,C)
   \tkzDrawPoints(A,B,C,A_1,B_1,C_1)
   \tkzLabelPoints(A,B,C,A_1,B_1,C_1)
   \tkzDrawPolygon[blue](A_1,B_1,C_1)
   \tkzText[right](0,-1){dot product =\tkzUseLua{x}}
   \end{tikzpicture}
\hspace*{\fill}
\end{minipage}

The scalar product of the vectors $\overrightarrow{AC}$ and $\overrightarrow{AB}$ is equal to $\tkzUseLua{x}$, so these vectors are orthogonal.
% subsection dot_or_scalar_product (end)

\subsection{Alignment or orthogonality} % (fold)
\label{sub:alignment_or_orthogonality}

With the functions |islinear| and |isortho|. |islinear(z.a,z.b,z.c)| gives |true| idf the points $a$, $b$ and $c$ are aligned.

|isortho(z.a,z.b,z.c)| gives |true| if the line $(ab)$ is orthogonal to the line $(ac)$.
% subsection alignment_or_orthogonality (end)

\subsection{Bisector and altitude} % (fold)
\label{sub:bisector_and_altitude}
These functions are useful if you don't need to create a useful triangle object for the rest of your code.

\begin{minipage}{.5\textwidth}
   \begin{verbatim}
\begin{tkzelements}
   z.a   = point: new (0, 0)
   z.b   = point: new (5, -2)
   z.c   = point: new (2, 3)
   z.i   = bisector (z.a,z.c,z.b).pb
   z.h   = altitude (z.b,z.a,z.c).pb
   angic = tkzround ( get_angle (z.a,z.i,z.c),2)
   angci = tkzround ( get_angle (z.a,z.b,z.i),2)
   z.e = bisector_ext (z.a,z.b,z.c).pb
\end{tkzelements}

\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPolygon(a,b,c)
   \tkzDrawSegments(a,i b,h a,e)
   \tkzDrawPoints(a,b,c,i,h)
   \tkzLabelPoints(a,b)
   \tkzLabelPoints[above](c,i,h)
   \tkzMarkAngle[->](i,a,c)
   \tkzLabelAngle[font=\tiny,pos=.75](i,a,c){\tkzUseLua{angci}}
   \tkzMarkAngle[<-](b,a,i)
   \tkzLabelAngle[font=\tiny,pos=.75](b,a,i){\tkzUseLua{angic}}
\end{tikzpicture}
   \end{verbatim}
\end{minipage}
\begin{minipage}{.5\textwidth}
\begin{tkzelements}
   z.a   = point: new (0, 0)
   z.b   = point: new (5, -2)
   z.c   = point: new (2, 3)
   z.i   = bisector (z.a,z.c,z.b).pb
   z.h   = altitude (z.b,z.a,z.c).pb
   angic = tkzround ( get_angle (z.a,z.i,z.c),2)
   angci = tkzround ( get_angle (z.a,z.b,z.i),2)
   z.e = bisector_ext (z.a,z.b,z.c).pb
\end{tkzelements}
\hspace{\fill}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPolygon(a,b,c)
   \tkzDrawSegments(a,i b,h a,e)
   \tkzDrawPoints(a,b,c,i,h)
   \tkzLabelPoints(a,b)
   \tkzLabelPoints[above](c,i,h)
   \tkzMarkAngle[->](i,a,c)
   \tkzLabelAngle[font=\tiny,pos=.75](i,a,c){\tkzUseLua{angci}}
   \tkzMarkAngle[<-](b,a,i)
   \tkzLabelAngle[font=\tiny,pos=.75](b,a,i){\tkzUseLua{angic}}
\end{tikzpicture}
\end{minipage}
% subsection bisector_and_altitude (end)

\subsection{Other functions} % (fold)
\label{sub:other_functions}

Not documented because still in beta version: |parabola|, |Cramer22|, |Cramer33|.

% subsection other_functions (end)
% section math_functions (end)

\endinput