Debian Codegraph @

texmf-dist/doc/latex/tkz-elements/TKZdoc-elements-classes-line.tex

raw
1 \newpage
2 \section{Class \tkzClass{line}} %(fold)
3
4 The variable \tkzVar{line}{L} holds a table used to store line objects. It is optional, and users are free to choose their own variable name (e.g., \tkzname{Lines}).
5 However, for consistency and readability, it is recommended to use \tkzVar{line}{L}. The function \tkzFct{tkz-elements}{init\_elements()} reinitializes this table automatically.
6
7
8 \subsection{Creating a line}
9 \label{sub:creating_a_line}
10
11 To define a line passing through two known points, use the following constructor:
12
13 \begin{mybox}
14 \code{L.AB = line(z.A, z.B)} \hfill (short form, recommended)\\
15 \code{L.AB = line:new(z.A, z.B)} \hfill (explicit form)
16 \end{mybox}
17
18 This creates a line object \code{L.AB} representing:
19 \begin{itemize}
20 \item the infinite line passing through points \code{z.A} and \code{z.B}, and
21 \item the segment $[AB]$, which is used to compute attributes such as the midpoint or direction.
22 \end{itemize}
23
24 \medskip
25
26 Internally, this object stores the two defining points and derives several geometric properties from them.
27
28 \subsection{Attributes of a line} %(fold)
29
30 Let's consider |L.AB = line(z.A, z.B)|
31
32 A line object provides access to the following attributes:
33
34 \vspace{1em}
35 \bgroup
36 \catcode`_=12
37 \small
38 \captionof{table}{Line attributes.}\label{line:attributes}
39 \begin{tabular}{lll}
40 \toprule
41 \texttt{Attribute} & \textbf{Meaning} & \texttt{Reference}\\
42 \midrule
43 \tkzAttr{line}{type} & Always \code{"line"} & \\
44 \tkzAttr{line}{pa} & First point (e.g., \code{z.A}) & \\
45 \tkzAttr{line}{pb} & Second point (e.g., \code{z.B}) & \\
46 \tkzAttr{line}{mid} & Midpoint of segment $[AB]$ & \\
47 \tkzAttr{line}{slope}& Angle with respect to the horizontal axis & [\ref{ssub:example_class_line}] \\
48 \tkzAttr{line}{length} & Euclidean distance $AB$ & \ref{ssub:example_class_line}] \\
49 \tkzAttr{line}{vec} & Vector $B - A$ & [\ref{sec:class_vector}] \\
50 \tkzAttr{line}{north\_pa} & Auxiliary point north of \code{pa} & [\ref{ssub:example_class_line}] \\
51 \tkzAttr{line}{north\_pb} & Auxiliary point north of \code{pb} & -- \\
52 \tkzAttr{line}{south\_pa} & Auxiliary point south of \code{pa} & -- \\
53 \tkzAttr{line}{south\_pb} & Auxiliary point south of \code{pb} & -- \\
54 \tkzAttr{line}{east} & Auxiliary point east of the segment & -- \\
55 \tkzAttr{line}{west} & Auxiliary point west of the segment & -- \\
56 \bottomrule
57 \end{tabular}
58 \egroup
59
60
61 \subsubsection{Example: attributes of class line} %(fold)
62 \label{ssub:example_class_line}
63
64 \vspace{1em}
65 \begin{minipage}{.5\textwidth}
66 \directlua{
67 init_elements()
68 z.a = point(1, 1)
69 z.b = point(5, 4)
70 L.ab = line(z.a, z.b)
71 z.m = L.ab.mid
72 z.w = L.ab.west
73 z.e = L.ab.east
74 z.r = L.ab.north_pa
75 z.s = L.ab.south_pb
76 sl = L.ab.slope
77 len = L.ab.length}
78 \begin{center}
79 \begin{tikzpicture}[scale = .5]
80 \tkzGetNodes
81 \tkzDrawPoints(a,b,m,e,r,s,w)
82 \tkzLabelPoints(a,b)
83 \tkzLabelPoint(r){north\_pa}
84 \tkzLabelPoint(s){south\_pb}
85 \tkzLabelPoint[below](m){mid}
86 \tkzLabelPoint[right](w){west}
87 \tkzLabelPoint[left](e){east}
88 \tkzDrawLine(a,b)
89 \tkzLabelSegment[above = 1em,sloped](a,b){ab = \pmpn{\tkzUseLua{len}}}
90 \tkzLabelSegment[above=2em,sloped](a,b){slope of(ab) = \pmpn{\tkzUseLua{sl}}}
91 \end{tikzpicture}
92 \end{center}
93 \end{minipage}
94 \begin{minipage}{.5\textwidth}
95 \begin{tkzexample}[code only]
96 \directlua{
97 init_elements()
98 z.a = point(1, 1)
99 z.b = point(5, 4)
100 L.ab = line(z.a, z.b)
101 z.m = L.ab.mid
102 z.w = L.ab.west
103 z.e = L.ab.east
104 z.r = L.ab.north_pa
105 z.s = L.ab.south_pb
106 sl = L.ab.slope
107 len = L.ab.length}
108 \end{tkzexample}
109 \end{minipage}
110
111 \subsubsection{Note on line object attributes}
112
113 To recover the original defining points of a line object \tkzname{L.name}, use either of the following:
114
115 \begin{itemize}
116 \item via the method \code{get(n)}, as in \code{z.A, z.B = L.name:get()} See [\ref{ssub:method_line_get},
117 \item or directly via its attributes \code{L.name.pa} and \code{L.name.pb}.
118 \end{itemize}
119 \newpage
120
121 \subsection{Methods of the class line} %(fold)
122
123 Here's the list of methods for the \tkzNameObj{line} object. The results can be real numbers, points, lines, circles or triangles. The triangles obtained are similar to the triangles defined below.
124
125 \begin{minipage}{\textwidth}
126 \bgroup
127 \catcode`_=12
128 \small
129 \captionof{table}{Methods of the class line.(part 1)}\label{line:methods part 1}
130 \begin{tabular}{ll}
131 \toprule
132 \texttt{Methods} & \texttt{Reference} \\
133 \midrule
134
135 \texttt{Constructor} & \\
136 \tkzMeth{line}{new(pt, pt)} &[\ref{sub:creating_a_line}; \ref{ssub:method_line_new_pt_pt}] \\
137
138 \midrule
139 \texttt{Methods Returning a Real Number} & \\
140 \midrule
141 \tkzMeth{line}{distance(pt)} & [\ref{ssub:method_line_distance}] \\
142 \midrule
143
144 \texttt{Methods Returning a Boolean} & \\
145
146 \tkzMeth{line}{on\_line(pt)} & [\ref{ssub:method_on_line}] \\
147 \tkzMeth{line}{on\_segment(pt)} & [\ref{ssub:method_on_segment}] \\
148 \tkzMeth{line}{is\_parallel(L)} & [\ref{ssub:method_line_is_parallel}] \\
149 \tkzMeth{line}{is\_orthogonal(L)} & [\ref{ssub:method_line_is_orthogonal}] \\
150 \tkzMeth{line}{is\_equidistant(pt)} & [\ref{ssub:method_line_is_equidistant}]\\
151 \midrule
152
153 \texttt{Methods Returning a String} & \\
154 \midrule
155
156 \tkzMeth{line}{position(pt)} & [\ref{ssub:method_line_position}] \\
157 \tkzMeth{line}{position\_segment(pt)} & [\ref{ssub:method_line_position_segment} \\
158 \tkzMeth{line}{where\_on\_line(pt)} & [\ref{ssub:method_line_where_on_line}] \\
159 \midrule
160
161 \texttt{Methods Returning a Point} & \\
162 \midrule
163 \tkzMeth{line}{get(n)} & [\ref{ssub:method_line_get}] \\
164 \tkzMeth{line}{random()} & [\ref{ssub:method_line_random}] \\
165 \tkzMeth{line}{gold\_ratio()}& [\ref{ssub:methode_imeth_line_gold__ratio}; \ref{sub:the_figure_pappus_circle}] \\
166
167 \tkzMeth{line}{normalize()} & [\ref{ssub:normalize}]\\
168 \tkzMeth{line}{normalize\_inv()} & [\ref{ssub:normalize}]\\
169 \tkzMeth{line}{barycenter(r,r)} & [\ref{ssub:barycenter_with_a_line}]\\
170 \tkzMeth{line}{point(r)} & [\ref{ssub:method_point}]\\
171 \tkzMeth{line}{midpoint()} & [\ref{ssub:method_line_midpoint}]\\
172 \tkzMeth{line}{harmonic\_int(pt)} & [\ref{ssub:method_line_harmonic_int}]\\
173 \tkzMeth{line}{harmonic\_ext(pt)} & [\ref{ssub:method_line_harmonic_ext}]\\
174 \tkzMeth{line}{harmonic\_both(r)} & [\ref{ssub:harmonic_both}]\\
175 \tkzMeth{line}{harmonic(mode, pt)} & [\ref{ssub:harmonic}]\\
176 \tkzMeth{line}{report(d,pt)} & [\ref{ssub:method_report}]\\
177 \tkzMeth{line}{collinear\_at(pt,k)}& [ex. \ref{ssub:method_line_collinear__at}]\\
178 \midrule
179
180 \texttt{Methods Returning a Line} & \\
181 \midrule
182 \tkzMeth{line}{ll\_from(pt)} & [\ref{ssub_line_from_a_defined_line}] \\
183 \tkzMeth{line}{ortho\_from(pt)} & [\ref{ssubline_ortho_from}] \\
184 \tkzMeth{line}{mediator()} & [\ref{ssub:method_line_mediator}]\\
185 \tkzMeth{line}{swap\_line()} & [\ref{ssub:method_line_swap__line} ; \ref{ssub:intersection_line_parabola_explained}] \\
186
187 \tkzMeth{line}{orthogonal\_at()} & \ref{ssub:method_line_orthogonal__at} \\
188 \bottomrule
189 \end{tabular}
190 \egroup
191 \end{minipage}
192
193 \begin{minipage}{\textwidth}
194 \bgroup
195 \catcode`_=12
196 \small
197 \captionof{table}{Methods of the class line.(part 2)}\label{line:methods part 2}
198 \begin{tabular}{lll}
199 \toprule
200 \texttt{Methods} & \texttt{Reference} & \\
201 \midrule
202 \texttt{Methods Returning a Triangle} & \\
203 \midrule
204 \tkzMeth{line}{equilateral(<'swap'>)} & [\ref{ssub:method_line_equilateral}; \ref{ssub:object_rotation}] \\
205
206 \tkzMeth{line}{isosceles(d,<'swap'>)}& [\ref{ssub:method_line_isosceles}]\\
207
208 \tkzMeth{line}{two\_angles(an,an)} & [\ref{ssub:triangle_with_two__angles}] \\
209 \tkzMeth{line}{school(<'swap'>)} & [\ref{ssub:method_imeth_line_school_swap}] \\
210 \tkzMeth{line}{half(<'swap'>)} & [\ref{ssub:method_imeth_line_half_swap}]\\
211 \tkzMeth{line}{s\_s(r,r<,'swap'>)} & [\ref{ssub:triangle_with_three_given_sides}] \\
212 \tkzMeth{line}{sa\_(r,an<,'swap'>)} & [\ref{ssub:_line_sas_d_an}] \\
213 \tkzMeth{line}{\_as(r,an<,'swap'>)} & [\ref{ssub:_line__as_d_an_swap}] \\
214 \tkzMeth{line}{a\_s(r,an<,'swap'>)} & [\ref{ssub:_line_a__s_d_an_swap}]\\
215 \tkzMeth{line}{s\_a(r,an<,'swap'>)} & [\ref{ssub:_line_sa}]\\
216 \midrule
217 \texttt{Methods Returning a Sacred Triangle}&\\
218 \midrule
219 \tkzMeth{line}{gold(<'swap'>)} & [\ref{ssub:method_line_gold}] \\
220 \tkzMeth{line}{golden(<'swap'>)} & or sublime [\ref{ssub:method_line_golden}] \\
221 \tkzMeth{line}{golden\_gnomon(<'swap'>)} & [\ref{ssub:method_line_golden__gnomon}] \\
222 \tkzMeth{line}{pythagoras(<'swap'>)} & or egyptian [\ref{ssub:_line_egyptian}] \\
223 \midrule
224 \texttt{Methods Returning a Circle} &\\
225 \midrule
226 \tkzMeth{line}{circle()} & \\
227 \tkzMeth{line}{apollonius(r)} & [\ref{ssub:apollonius_circle_ma_mb_k}] \\
228 \tkzMeth{line}{LPP} & or c\_l\_pp(pt, pt) [\ref{ssub:c_l_pp}] \\
229 \tkzMeth{line}{LLP} & or c\_ll\_p(L, pt) [\ref{ssub:method_c__ll__p}] \\
230 \tkzMeth{line}{LLL(L, L)} & [\ref{ssub:method_LLL}] \\
231 \midrule
232 \texttt{Methods Returning a Square}&\\
233 \midrule
234 \tkzMeth{line}{square()} & [\ref{ssub:object_rotation}] \\
235 \midrule
236 \texttt{Methods Returning a Object} &\\
237 \midrule
238 \tkzMeth{line}{reflection(obj)} & [\ref{ssub:reflection_of_object}] \\
239 \tkzMeth{line}{translation(obj)} & [\ref{ssub:example_translation}] \\
240 \tkzMeth{line}{projection(obj)} & [\ref{ssub:example_projection_of_several_points}]\\
241 \tkzMeth{line}{projection\_ll(L, pts)} & [\ref{ssub:method_line_projection__ll}] \\
242 \tkzMeth{line}{affinity\_ll(L, k, pts)} & [\ref{ssub:method_line_affinity}] \\
243
244 \texttt{Methods Returning a Path} &\\
245 \midrule
246 \tkzMeth{line}{path(n)} & [\ref{ssub:line_path}] \\
247 \bottomrule
248 \end{tabular}
249 \egroup
250 \end{minipage}
251
252 \subsubsection{Method \tkzMeth{line}{new(pt,pt)}} %(fold)
253 \label{ssub:method_line_new_pt_pt}
254
255 It is preferable to use syntax such as \code{L.xx} and it's also preferable to use the short form \code{line(pt, pt)}.
256
257 \begin{tkzexample}[latex=.5\textwidth]
258 \directlua{
259 init_elements()
260 z.A = point(0, 0)
261 z.B = point(4, 3)
262 L.AB = line(z.A, z.B)}
263 \begin{center}
264 \begin{tikzpicture}
265 \tkzGetNodes
266 \tkzDrawLine(A,B)
267 \tkzDrawPoints(A,B)
268 \tkzLabelPoints(A,B)
269 \end{tikzpicture}
270 \end{center}
271 \end{tkzexample}
272
273 \subsection{Returns a real number}
274
275 Only one method in this category
276
277
278 \subsubsection{Method \tkzMeth{line}{distance(pt)}} %(fold)
279 \label{ssub:method_line_distance}
280
281 This method gives the distance from a point to a straight line.
282
283 \vspace{1em}
284
285 \begin{tkzexample}[latex=.5\textwidth]
286 \directlua{
287 init_elements()
288 z.A = point(0, 0)
289 z.B = point(4, 3)
290 z.C = point(1, 5)
291 L.AB = line(z.A, z.B)
292 d = L.AB:distance(z.C)
293 l = L.AB.length
294 z.H = L.AB:projection(z.C)}
295 \begin{center}
296 \begin{tikzpicture}
297 \tkzGetNodes
298 \tkzDrawLines(A,B C,H)
299 \tkzDrawPoints(A,B,C,H)
300 \tkzLabelPoints(A,B,C,H)
301 \tkzLabelSegment[above right=2em,draw](C,H){%
302 $CH = \tkzUseLua{d}$}
303 \tkzLabelSegment[below right=1em,draw](A,B){%
304 $AB = \tkzUseLua{l}$}
305 \end{tikzpicture}
306 \end{center}
307 \end{tkzexample}
308
309 \subsection{Returns a boolean}
310
311
312
313 \subsubsection{Method \tkzMeth{line}{on\_line(pt)}} %(fold)
314 \label{ssub:method_on_line}
315 %
316 This method is a boolean wrapper of \tkzMeth{line}{position(pt)}.
317
318 It returns \code{true} if the point lies on the line and \code{false} otherwise.
319
320 The method can also be called using \code{L:on\_line(pt)}.
321
322 \texttt{Note: }
323 This method is kept for backward compatibility.
324
325 \vspace{1em}
326
327 \begin{tkzexample}[latex=.5\textwidth]
328 \directlua{
329 init_elements()
330 local function calc_distance(L, p)
331 if L:on_line(p) then
332 return point.abs(p - L.pa) / L.length
333 else
334 return 0
335 end
336 end
337 z.A = point(0, 0)
338 z.B = point(2, 4)
339 z.X = point(3, 6)
340 z.Y = point(2, 0)
341 L.AB = line(z.A, z.B)
342 dx = calc_distance(L.AB, z.X)
343 dy = calc_distance(L.AB, z.Y)}
344 \begin{center}
345 \begin{tikzpicture}
346 \tkzGetNodes
347 \tkzDrawLine(A,B)
348 \tkzDrawPoints(A,B,X,Y)
349 \tkzLabelPoints(A,B)
350 \tkzLabelPoint(X){X: \tkzUseLua{dx}}
351 \tkzLabelPoint(Y){Y: \tkzUseLua{dy}}
352 \end{tikzpicture}
353 \end{center}
354 \end{tkzexample}
355
356
357
358 %
359 \subsubsection{Method \tkzMeth{line}{on\_segment(pt)}} %(fold)
360 \label{ssub:method_on_segment}
361
362 Variant of the previous method; indicates whether a point is on or off a segment.
363
364
365 Boolean wrapper of \tkzMeth{line}{position\_segment(pt)}.
366
367 \texttt{Returns: } \code{true} if \tkzMeth{line}{position\_segment(pt)} returns \code{"ON"},
368 and \code{false} otherwise.
369
370 \texttt{Note: } Kept for backward compatibility.
371
372 \texttt{Returns: }
373
374 \begin{itemize}
375 \item \code{true} if the point lies on the segment $[pa,pb]$,
376 \item \code{false} otherwise.
377 \end{itemize}
378
379 \vspace{1em}
380
381 \begin{tkzexample}[latex=.5\textwidth]
382 \directlua{
383 init_elements()
384 local function inseg(L, p)
385 if L:on_segment(p) then
386 return "IN"
387 else
388 return "OUT"
389 end
390 end
391 z.A = point(0, 0)
392 z.B = point(2, 4)
393 z.X = point(-1,-2)
394 z.Y = point(1, 2)
395 L.AB = line(z.A, z.B)
396 dx = inseg(L.AB, z.X)
397 dy = inseg(L.AB, z.Y)}
398 \begin{center}
399 \begin{tikzpicture}
400 \tkzGetNodes
401 \tkzDrawLine(A,B)
402 \tkzDrawPoints(A,B,X,Y)
403 \tkzLabelPoints(A,B)
404 \tkzLabelPoint(X){X: \tkzUseLua{dx}}
405 \tkzLabelPoint(Y){Y: \tkzUseLua{dy}}
406 \end{tikzpicture}
407 \end{center}
408 \end{tkzexample}
409
410 \subsubsection{Method \tkzMeth{line}{is\_parallel(L)}} %(fold)
411 \label{ssub:method_line_is_parallel}
412
413 \vspace{1em}
414 \begin{tkzexample}[latex=.5\textwidth]
415 \directlua{
416 init_elements()
417 z.A = point(0, 0)
418 z.B = point(4, 2)
419 L.AB = line(z.A, z.B)
420 z.C = point(1, 2)
421 z.D = point(5, 4)
422 L.CD = line(z.C, z.D)
423 if L.AB:is_parallel(L.CD)
424 then tkztxt = "parallel"
425 else tkztxt = "no parallel"
426 end}
427 \begin{center}
428 \begin{tikzpicture}
429 \tkzGetNodes
430 \tkzDrawLines(A,B C,D)
431 \tkzDrawPoints(A,B,C,D)
432 \tkzLabelPoints(A,B,C,D)
433 \tkzLabelSegment[sloped,pos=.3](C,D){%
434 $(CD)\ \tkzUseLua{tkztxt}\ (AB)$}
435 \end{tikzpicture}
436 \end{center}
437 \end{tkzexample}
438
439 \subsubsection{Method \tkzMeth{line}{is\_orthogonal(L)}} %(fold)
440 \label{ssub:method_line_is_orthogonal}
441
442 \vspace{1em}
443
444 \begin{tkzexample}[latex=.5\textwidth]
445 \directlua{
446 init_elements()
447 z.A = point(0, 0)
448 z.B = point(0, 4)
449 L.AB = line(z.A, z.B)
450 z.C = point(5, 4)
451 L.BC = line(z.B, z.C)
452 if L.AB:is_orthogonal(L.BC) then
453 tkztxt = "orthogonal"
454 else
455 tkztxt = "no orthogonal"
456 end}
457 \begin{center}
458 \begin{tikzpicture}
459 \tkzGetNodes
460 \tkzDrawLines(A,B B,C A,C)
461 \tkzDrawPoints(A,B,C)
462 \tkzLabelPoints(A,B,C)
463 \tkzLabelSegment[sloped,pos=.3](B,C){%
464 $(BC)\ \tkzUseLua{tkztxt}\ (AB)$}
465 \end{tikzpicture}
466 \end{center}
467 \end{tkzexample}
468
469 \subsubsection{Method \tkzMeth{line}{is\_equidistant(pt)}} %(fold)
470 \label{ssub:method_line_is_equidistant}
471
472 Is a point equidistant from the two points that define the line?
473
474 \begin{tkzexample}[latex=.5\textwidth]
475 \directlua{
476 init_elements()
477 z.A = point(0, 0)
478 z.B = point(0, 4)
479 z.C = point(4, 4)
480 L.AC = line(z.A, z.C)
481 if L.AC:is_equidistant(z.B) then
482 tkztxt = "equidistant"
483 else
484 tkztxt = "no equidistant"
485 end}
486 \begin{center}
487 \begin{tikzpicture}
488 \tkzGetNodes
489 \tkzDrawLines(A,B B,C A,C)
490 \tkzDrawPoints(A,B,C)
491 \tkzLabelPoints(A,B,C)
492 \tkzLabelSegment[sloped,pos=.3](A,C){%
493 $B \ \tkzUseLua{tkztxt}\ of A\ and\ C$}
494 \end{tikzpicture}
495 \end{center}
496 \end{tkzexample}
497
498 \subsection{Returns a string}
499
500 \subsubsection{Method \tkzMeth{line}{position(obj[,EPS])}}
501 \label{ssub:method_line_position}
502
503 This method classifies the relative position between the current line and another object.
504 The returned value is a \emph{symbolic string} whose meaning depends on the type of \code{obj}.
505 All tests are performed with a numerical tolerance.
506
507 \medskip
508 \textbf{Arguments:}
509 \begin{itemize}
510 \item \code{obj}: a \tkzClass{point}, \tkzClass{line}, or \tkzClass{circle};
511 \item \code{EPS} (optional): numerical tolerance. If omitted, \code{tkz.epsilon} is used.
512 \end{itemize}
513
514 \medskip
515 \textbf{Returns:}
516 \begin{itemize}
517 \item If \code{obj} is a \tkzClass{point}: returns \code{"ON"} if the point lies on the line (within tolerance),
518 otherwise \code{"OUT"}.
519 \item If \code{obj} is a \tkzClass{line}: returns the result of \code{line\_line\_position\_(self,obj,EPS)}.
520 \item If \code{obj} is a \tkzClass{circle}: returns the result of \code{line\_circle\_position\_(self,obj,EPS)}.
521 \end{itemize}
522
523 \medskip
524 \textbf{Note:}
525 The method is a dispatcher based on \code{getmetatable(obj)} and uses \code{tkz.epsilon} by default.
526
527
528 \subsubsection{Method \tkzMeth{line}{position\_segment(pt)}}
529 \label{ssub:method_line_position_segment}
530
531 This method determines the position of a point relative to the segment
532 $[pa,pb]$ defined by the line object.
533
534 \texttt{Arguments: } \code{pt}: a point.
535
536 \texttt{Returns: }
537 \begin{itemize}
538 \item \code{"ON"} if the point lies on the segment (within tolerance),
539 \item \code{"OUT"} otherwise.
540 \end{itemize}
541
542 \texttt{Note: } The method uses the numerical tolerance \code{tkz.epsilon}.
543
544
545 \subsubsection{Method \tkzMeth{line}{where\_on\_line(pt)}}
546 \label{ssub:method_line_where_on_line}
547
548 This method determines the \emph{oriented position} of a point \code{pt} along a line,
549 considered as oriented from its first defining point \code{pa} to its second one
550 \code{pb}.
551
552 \medskip
553
554 The method assumes that the line is oriented from \code{pa} to \code{pb}.
555 It first checks whether the point lies on the line (within a tolerance).
556 If this is not the case, the method returns \code{nil}.
557
558
559 \medskip
560
561 \paragraph{Arguments.}
562 \begin{itemize}
563 \item \code{pt}: a point.
564 \end{itemize}
565
566 \paragraph{Returns.}
567 \begin{itemize}
568 \item \code{"BEFORE"} if \code{pt} lies on the line \emph{before} \code{pa};
569 \item \code{"BETWEEN"} if \code{pt} lies on the segment $[pa,pb]$ (i.e.\ between \code{pa} and \code{pb});
570 \item \code{"AFTER"} if \code{pt} lies on the line \emph{after} \code{pb};
571 \item \code{nil} if \code{pt} does not lie on the line.
572 \end{itemize}
573
574 \paragraph{Notes.}
575 \begin{itemize}
576 \item Reversing the order of the defining points \code{pa} and \code{pb}
577 reverses the meaning of ``BEFORE'' and ``AFTER''.
578 \item The method uses a numerical tolerance \code{tkz.epsilon}.
579 \end{itemize}
580
581
582
583
584 \subsection{Returns a point}
585
586
587 \subsubsection{Method \tkzMeth{line}{get()}}
588 \label{ssub:method_line_get}
589
590 This method retrieves the two points that define the given line. It is useful, for example, when constructing a line through a specific point and parallel to another: you need two points to define the direction.
591
592 \begin{itemize}
593 \item \code{L.AB:get()} returns the two points \code{pa} and \code{pb}.
594 \item \code{L.AB:get(1)} returns the first point \code{pa}.
595 \item \code{L.AB:get(2)} returns the second point \code{pb}.
596 \end{itemize}
597
598 This method is available for most geometric objects that are defined by two or more points (e.g., lines, triangles, circles). It allows for easy reuse and composition of geometric constructions.
599
600
601 \begin{tkzexample}[latex=.35\textwidth]
602 \directlua{
603 init_elements()
604 z.A = point(1, 1)
605 z.B = point(2, 2)
606 L.AB = line(z.A, z.B)
607 z.C = L.AB.north_pa
608 z.D = L.AB:ll_from(z.C):get(2)}
609
610 \begin{tikzpicture}
611 \tkzGetNodes
612 \tkzDrawLines(A,B C,D)
613 \tkzDrawPoints(A,B,C,D)
614 \tkzLabelPoints(A,B,C,D)
615 \end{tikzpicture}
616 \end{tkzexample}
617
618
619 \subsubsection{Method \tkzMeth{line}{report(r,<pt>)}} %(fold)
620 \label{ssub:method_report}
621
622 \texttt{Purpose: } This method constructs and returns a \tkzname{point} located at a given distance \( r \) from a reference point along the direction of the line.
623
624 \medskip
625
626 It generalizes the idea of “reporting a length” on a line segment. Depending on whether a reference point is specified, the method either measures from the first endpoint of the line or from a user-defined origin.
627
628 \texttt{Syntax: }
629
630 \begin{center}
631 \begin{tabular}{lcl}
632 \code{L:report(r)} & $\rightarrow$ & returns the point at distance \( r \) from \code{L.pa} along \code{L.pb} \\
633 \code{L:report(r, pt)} & $\rightarrow$ & returns the point at distance \( r \) from \code{pt} parallel to \code{L}
634 \end{tabular}
635 \end{center}
636
637 \texttt{Arguments: }
638
639 \begin{description}
640 \item[\code{r}] (number) — the signed distance to report along the line.
641 If \(\,r>0\), the point lies in the direction from \code{pa} to \code{pb};
642 if \(\,r<0\), it lies in the opposite direction.
643 \item[\code{pt}] (optional \tkzname{point}) — an optional reference point from which to start measuring the distance.
644 \end{description}
645
646
647 \texttt{Special cases: }
648
649 \begin{itemize}
650 \item If the line has zero length (i.e., both endpoints coincide), an error is raised.
651 \item Negative distances produce points on the opposite extension of the line.
652 \item The method works consistently with open or oriented lines (not just finite segments).
653 \end{itemize}
654
655 \texttt{Alias: } The synonym \code{point\_at\_distance} is provided for readability, especially when the geometrical intent is to “locate a point at a given distance along a direction”.
656
657 \texttt{Returned value: }
658 A new \tkzname{point} object corresponding to the computed location.
659
660
661 \vspace{1em}
662 \begin{tkzexample}[latex=.5\textwidth]
663 \directlua{
664 init_elements()
665 z.A = point(0, 0)
666 z.B = point(4, 3)
667 L.AB = line(z.A, z.B)
668 z.M = point(0, 2)
669 z.N = L.AB:report(2.5, z.M)
670 z.O = L.AB:report(2.5)
671 z.P = L.AB:report(-L.AB.length/3,z.M)}
672 \begin{center}
673 \begin{tikzpicture}
674 \tkzGetNodes
675 \tkzDrawSegments(A,B P,N)
676 \tkzDrawPoints(A,B,M,N,O,P)
677 \tkzLabelPoints(A,B,M,N,O,P)
678 \end{tikzpicture}
679 \end{center}
680 \end{tkzexample}
681
682 \subsubsection{Method \tkzMeth{line}{barycenter(ka, kb)}} %(fold)
683 \label{ssub:barycenter_with_a_line}
684
685 This method returns the barycenter of the two points that define the line, weighted by the coefficients \code{ka} and \code{kb}.
686
687 \medskip
688
689 Geometrically, the barycenter lies on the line segment $[AB]$ (or its extension) and divides it internally or externally, depending on the sign and ratio of the coefficients.
690
691
692 \begin{tkzexample}[latex=.5\textwidth]
693 \directlua{
694 init_elements()
695 z.A = point(0, -1)
696 z.B = point(4, 2)
697 L.AB = line(z.A, z.B)
698 z.G = L.AB:barycenter(1, 2)}
699 \begin{center}
700 \begin{tikzpicture}
701 \tkzGetNodes
702 \tkzDrawLine(A,B)
703 \tkzDrawPoints(A,B,G)
704 \tkzLabelPoints(A,B,G)
705 \end{tikzpicture}
706 \end{center}
707 \end{tkzexample}
708
709 \subsubsection{Method \tkzMeth{line}{point(r)} }%(fold)
710 \label{ssub:method_point}
711
712 This method is very useful: it allows you to place a point on the line, based on a real parameter \code{r}.
713
714 \begin{itemize}
715 \item If \code{r = 0}, the result is the point \code{pa}.
716 \item If \code{r = 1}, the result is the point \code{pb}.
717 \item If \code{r = 0.5}, the result is the midpoint of the segment $[AB]$.
718 \item Any value of \code{r} is allowed: a negative value places the point before \code{pa}, a value greater than 1 places it beyond \code{pb}.
719 \end{itemize}
720
721 This method is implemented for all objects that are defined by at least two points, except for quadrilaterals.
722
723
724 \begin{minipage}{.5\textwidth}
725 \directlua{
726 init_elements()
727 z.A = point(-1, -1)
728 z.B = point(1, 1)
729 L.AB = line(z.A, z.B)
730 z.I = L.AB: point(0.75)
731 z.J = L.AB: point(1.2)}
732 \begin{center}
733 \begin{tikzpicture}[gridded]
734 \tkzGetNodes
735 \tkzDrawLine(A,J)
736 \tkzDrawPoints(A,B,I,J)
737 \tkzLabelPoints(A,B,I,J)
738 \end{tikzpicture}
739 \end{center}
740 \end{minipage}
741 \begin{minipage}{.5\textwidth}
742 \begin{tkzexample}[code only]
743 \directlua{
744 init_elements()
745 z.A = point(-1, -1)
746 z.B = point(1, 1)
747 L.AB = line(z.A, z.B)
748 z.I = L.AB: point(0.75)
749 z.J = L.AB: point(1.2)}
750 \end{tkzexample}
751 \end{minipage}
752
753 \subsubsection{Method \tkzMeth{line}{midpoint()}}
754 \label{ssub:method_line_midpoint}
755
756 This method has been replaced by \code{tkz.midpoint} [See \ref{sub:midpoint_and_midpoints}].
757
758 You can obtain the midpoint of a segment using an attribute of the \code{line} object.
759
760 \begin{center}
761 \code{z.M = L.AB.mid}
762 \end{center}
763
764 \medskip
765
766 However, when the line object has not been created and its creation is unnecessary, the standalone function \code{tkz.midpoint(z.A, z.B)} remains convenient and efficient.
767
768
769 \subsubsection{Method \tkzMeth{line}{harmonic\_int(pt)}}
770 \label{ssub:method_line_harmonic_int}
771
772 Given a point on the line but located \emph{outside} the segment $[AB]$, this method returns a point on the segment that maintains a harmonic ratio.
773
774 \medskip
775
776 Let $AB$ be a line, and let $D$ be a point such that $D \in (AB)$ but $D \not\in [AB]$. The method returns a point $C \in [AB]$ such that:
777
778 \[
779 \frac{AC}{BC} = \frac{AD}{BD}
780 \]
781
782
783 This construction is particularly useful in projective geometry and when working with harmonic divisions.
784
785 \vspace{2em}
786 \begin{tkzexample}[vbox,overhang]
787 \directlua{
788 init_elements()
789 z.A = point(0, 0)
790 z.B = point(6, 0)
791 z.D = point(8, 0)
792 L.AB = line(z.A, z.B)
793 z.C = L.AB:harmonic_int(z.D)}
794 \begin{center}
795 \begin{tikzpicture}
796 \tkzGetNodes
797 \tkzDrawLine(A,D)
798 \tkzDrawPoints(A,B,C,D)
799 \tkzLabelPoints(A,B,C,D)
800 \end{tikzpicture}
801 \end{center}
802
803 \end{tkzexample}
804
805 \subsubsection{Method \tkzMeth{line}{harmonic\_ext(pt)}}
806 \label{ssub:method_line_harmonic_ext}
807 This method returns a point located outside the segment $[AB]$ that satisfies a harmonic relation with a given point on the segment.
808
809 \medskip
810
811 Let $AB$ be a line segment, and let $C$ be a point on $[AB]$ (but not its midpoint). The method returns a point $D$ lying on the line $(AB)$ but \emph{outside} the segment $[AB]$, such that:
812
813 \[
814 \frac{AC}{BC} = \frac{AD}{BD}
815 \]
816
817
818 This is the inverse of the operation performed by the method \tkzMeth{line}{harmonic\_int(pt)}.
819
820 \subsubsection{Method \tkzMeth{line}{harmonic\_both(k)}}
821 \label{ssub:harmonic_both}
822
823 This method returns two points on the line defined by $AB$:
824
825 \begin{itemize}
826 \item one point $C$ lying \emph{inside} the segment $[AB]$,
827 \item one point $D$ lying \emph{outside} the segment $[AB]$,
828 \end{itemize}
829
830 such that the following harmonic ratio holds:
831
832 \[
833 \frac{AC}{BC} = \frac{AD}{BD} = k
834 \]
835
836
837 The parameter \code{k} represents the desired ratio between the distances. This method is useful when you want to construct both the internal and external harmonic conjugates of a given segment.
838
839 \medskip
840
841 The method returns the two corresponding points in the order: \code{internal, external}.
842
843 \vspace{2em}
844 \begin{tkzexample}[vbox,overhang]
845 \directlua{
846 init_elements()
847 z.A = point(0, 0)
848 z.B = point(6, 0)
849 L.AB = line(z.A, z.B)
850 z.C, z.D = L.AB:harmonic_both(5)}
851 \begin{center}
852 \begin{tikzpicture}
853 \tkzGetNodes
854 \tkzDrawLine(A,D)
855 \tkzDrawPoints(A,B,C,D)
856 \tkzLabelPoints(A,B,C,D)
857 \end{tikzpicture}
858 \end{center}
859 \end{tkzexample}
860
861 \subsubsection{Method \tkzMeth{line}{harmonic(mode, arg)}}
862 \label{ssub:harmonic}
863
864 This method provides a unified interface for harmonic division.
865
866 \begin{itemize}
867 \item \code{mode = "internal"} returns the internal harmonic point.
868 \item \code{mode = "external"} returns the external harmonic point.
869 \item \code{mode = "both"} returns both harmonic points.
870 \end{itemize}
871
872 The argument \code{arg} is:
873 \begin{itemize}
874 \item a point when \code{mode} is \code{"internal"} or \code{"external"},
875 \item a ratio when \code{mode} is \code{"both"}.
876 \end{itemize}
877
878 \medskip
879 \noindent\textbf{Example}
880 \begin{verbatim}
881 H1 = L.AB:harmonic("internal", z.P)
882 H2 = L.AB:harmonic("external", z.P)
883 Hi, He = L.AB:harmonic("both", 2)
884 \end{verbatim}
885
886
887
888
889 \subsubsection{Methode \tkzMeth{line}{gold\_ratio}}
890 \label{ssub:methode_imeth_line_gold__ratio}
891
892 This method returns a point $C$ on the segment $[AB]$ that divides it according to the \smallbf{golden ratio}~$\varphi$:
893
894 \[
895 \frac{AC}{CB} = \varphi = \frac{1 + \sqrt{5}}{2} \approx 1.618
896 \]
897
898
899 This construction is useful in design, geometry, and aesthetics where harmonic proportions are desired.
900
901 \begin{tkzexample}[vbox]
902 \directlua{
903 init_elements()
904 z.A = point(0, 0)
905 z.B = point(6, 0)
906 L.AB = line(z.A, z.B)
907 z.C = L.AB:gold_ratio()
908 AC = tkz.length(z.A, z.C)
909 BC = tkz.length(z.B, z.C)}
910
911 AC/BC = \tkzUseLua{AC / BC}
912
913 $\varphi = \tkzUseLua{(math.sqrt(5)+1)/2}$
914
915 \begin{center}
916 \begin{tikzpicture}
917 \tkzGetNodes
918 \tkzDrawLine(A,B)
919 \tkzDrawPoints(A,B,C)
920 \tkzLabelPoints(A,B,C)
921 \end{tikzpicture}
922 \end{center}
923
924 \end{tkzexample}
925
926 \subsubsection{Method \tkzMeth{line}{normalize()} and \tkzMeth{line}{normalize\_inv()}} %(fold)
927 \label{ssub:normalize}
928
929 $ac = 1$ and $c\in [ab]$
930
931 $bd = 1$ and $d\in [ab]$
932
933 \vspace{1em}
934 \begin{tkzexample}[latex=.5\textwidth]
935 \directlua{
936 init_elements()
937 z.a = point(1, 1)
938 z.b = point(5, 4)
939 L.ab = line(z.a, z.b)
940 z.c = L.ab:normalize()
941 z.d = L.ab:normalize_inv()
942 }
943 \begin{center}
944 \begin{tikzpicture}[gridded]
945 \tkzGetNodes
946 \tkzDrawSegments(a,b)
947 \tkzDrawCircle(a,c)
948 \tkzDrawPoints(a,b,c,d)
949 \tkzLabelPoints(a,b,c,d)
950 \end{tikzpicture}
951 \end{center}
952 \end{tkzexample}
953
954 \subsubsection{Method \tkzMeth{line}{collinear\_at(pt,<r>)}} %(fold)
955 \label{ssub:method_line_collinear__at}
956
957 This method returns a point located on a line parallel to $(AB)$ and passing through a given point.
958 The resulting point is placed at a distance proportional to the length of $AB$, in the same direction.
959
960 \medskip
961
962 If the second argument \meta{r} is omitted, it defaults to $1$.
963 In that case, the method produces a segment of the same length and direction as $[AB]$.
964
965 \medskip
966
967 In addition to the scale-factor form, this method also accepts an option table
968 \code{\{length =~$\ell$\}}, allowing the distance $CD$ to be specified
969 \emph{absolutely}, independently of~$AB$.
970
971 \medskip
972
973 \textbf{Example interpretations:}
974 \begin{itemize}
975 \item If \code{L.AB:collinear\_at(z.C)} produces point $E$, then $CE = AB$ and $(AB) \parallel (CE)$.
976 \item If \code{L.AB:collinear\_at(z.C, 0.5)} produces point $D$, then $CD = 0.5 \cdot AB$ and $(AB) \parallel (CD)$.
977 \item If \code{L.AB:collinear\_at(z.C, \{length = 2\})} produces point $F$, then $CF = 2$ (in the current unit) and $(AB) \parallel (CF)$. It is also possible to use a negative value.
978 \end{itemize}
979
980 This is particularly useful for replicating a vector or projecting a direction onto another position in the plane.
981
982 \vspace{1em}
983 \begin{tkzexample}[latex =.5\textwidth]
984 \directlua{
985 init_elements()
986 z.A = point(0, 0)
987 z.B = point(4, 0)
988 z.C = point(1, 3)
989 L.AB = line(z.A, z.B)
990 z.D = L.AB:collinear_at(z.C, .5)
991 z.E = L.AB:collinear_at(z.C)
992 z.F = L.AB:collinear_at(z.C, {length = -3})}
993 \begin{center}
994 \begin{tikzpicture}
995 \tkzGetNodes
996 \tkzDrawSegments(A,B C,E C,F)
997 \tkzDrawPoints(A,B,C,D,E,F)
998 \tkzLabelPoints(A,B,C,D,E,F)
999 \end{tikzpicture}
1000 \end{center}
1001 \end{tkzexample}
1002
1003
1004 \subsubsection{Method \tkzMeth{line}{orthogonal\_at(pt,<r>)}} %(fold)
1005 \label{ssub:method_line_orthogonal__at}
1006
1007 This method returns a point located on a line \textbf{perpendicular} to the line $(AB)$, passing through a given point.
1008
1009 The resulting point is placed at a distance proportional to the length of $AB$, in a direction orthogonal to it.
1010 By default, if the second argument is omitted, the factor is $1$.
1011
1012 \medskip
1013 In addition to the scale factor form, this method also accepts an option table
1014 \code{\{length =~$\ell$\}}, allowing the distance $CD$ to be specified
1015 \emph{absolutely}, independently of~$AB$.
1016
1017 \medskip
1018
1019 \texttt{Example interpretations:}
1020 \begin{itemize}
1021 \item If \code{L.AB:orthogonal\_at(z.C)} gives point $E$, then $CE = AB$ and $(AB) \perp (CE)$.
1022 \item If \code{L.AB:orthogonal\_at(z.C, 0.5)} gives point $D$, then $CD = 0.5 \cdot AB$ and $(AB) \perp (CD)$.
1023 \item If \code{L.AB:orthogonal\_at(z.C, \{length = 2\})} gives point $F$, then $CF = 2$ (in the current unit) and $(AB) \perp (CF)$. It is also possible to use a negative value.
1024 \end{itemize}
1025
1026 This method is useful for constructing perpendicular vectors or building geometric figures such as rectangles or perpendicular bisectors.
1027
1028 \vspace{1em}
1029 \begin{tkzexample}[latex =.5\textwidth]
1030 \directlua{
1031 init_elements()
1032 z.A = point(0, 0)
1033 z.B = point(2, 0)
1034 z.C = point(1, 1)
1035 L.AB = line(z.A, z.B)
1036 z.D = L.AB:orthogonal_at(z.C, .5)
1037 z.E = L.AB:orthogonal_at(z.C)
1038 z.F = L.AB:orthogonal_at(z.C, {length = -3})}
1039 \begin{center}
1040 \begin{tikzpicture}
1041 \tkzGetNodes
1042 \tkzDrawSegments(A,B C,E C,F)
1043 \tkzDrawPoints(A,B,C,D,E,F)
1044 \tkzLabelPoints(A,B,C,D,E,F)
1045 \end{tikzpicture}
1046 \end{center}
1047 \end{tkzexample}
1048
1049
1050
1051 \subsubsection{Method \tkzMeth{line}{random()}}
1052 \label{ssub:method_line_random}
1053 The method returns a point belonging to the segment.
1054
1055 \medskip
1056 \texttt{Syntax: } \verb|z.M = L.AB:random()|
1057
1058
1059 %%================================
1060 \subsection{Returns a line}
1061 %%================================
1062
1063 \subsubsection{Method \tkzMeth{line}{ll\_from(pt)}} %(fold)
1064 \label{ssub_line_from_a_defined_line}
1065
1066 \medskip
1067 \texttt{Alias: } \code{parallel\_from}
1068
1069
1070 \texttt{Purpose: } This method constructs a new object of type \code{line}, parallel to the original line and passing through the given point.
1071
1072 \medskip
1073
1074 Unlike the \code{collinear\_at} method, which simply returns a point translated along the same direction, \code{ll\_from} returns a full line object. This allows further operations such as intersections, projections, or constructions involving new points along that line.
1075
1076 \medskip
1077
1078 \texttt{Use this method when you need a new line object rather than a point.}.
1079
1080 The choice between \code{ll\_from} and \code{collinear\_at} depends on the context and on whether you need to work with the resulting direction as a geometric object.
1081
1082 \begin{minipage}{.5\textwidth}
1083 \directlua{
1084 init_elements()
1085 z.A = point(1, 1)
1086 z.B = point(2, 2)
1087 L.AB = line(z.A, z.B)
1088 z.C = L.AB.north_pa
1089 z.D = L.AB.south_pa
1090 L.CD = line(z.C, z.D)
1091 _, z.E = L.CD:ll_from(z.B):get()}
1092 \begin{center}
1093 \begin{tikzpicture}
1094 \tkzGetNodes
1095 \tkzDrawLines(A,B C,D B,E)
1096 \tkzDrawPoints(A,...,E)
1097 \tkzLabelPoints(A,...,E)
1098 \tkzMarkRightAngle(B,A,C)
1099 \tkzMarkSegments(A,C A,B A,D)
1100 \end{tikzpicture}
1101 \end{center}
1102 \end{minipage}
1103 \begin{minipage}{.5\textwidth}
1104 \begin{tkzexample}[code only]
1105 \directlua{
1106 init_elements()
1107 z.A = point(1, 1)
1108 z.B = point(2, 2)
1109 L.AB = line(z.A, z.B)
1110 z.C = L.AB.north_pa
1111 z.D = L.AB.south_pa
1112 L.CD = line(z.C, z.D)
1113 _, z.E = L.CD:ll_from(z.B):get()}
1114 \end{tkzexample}
1115 \end{minipage}
1116 %\begin{table}[h!]
1117
1118
1119 \subsubsection{Comparison between \texttt{collinear\_at} and \texttt{ll\_from} methods}
1120
1121 \bgroup
1122 \small
1123 \begin{tabular}{@{} l ll @{}}
1124 \toprule
1125 \smallbf{Aspect} & \code{collinear\_at(pt, r)} & \code{ll\_from(pt)} \\
1126 \midrule
1127 Return type & \code{point} & \code{line} \\
1128 Purpose & Translated point & Parallel line \\
1129 Input & Point, scalar (optional) & Point \\
1130 Default scalar & \code{r = 1} & N/A \\
1131 Use case & Vector displacement & Parallel construction \\
1132 \bottomrule
1133 \end{tabular}
1134 \egroup
1135
1136
1137 \subsubsection{Method \tkzMeth{line}{ortho\_from(pt)}} %(fold)
1138 \label{ssubline_ortho_from}
1139
1140 \texttt{Alias: } \code{orthogonal\_from}
1141
1142
1143 \texttt{Purpose: } This method constructs a new object of type \code{line}, perpendicular to the original line and passing through the given point.
1144
1145 \medskip
1146
1147 Unlike the \code{orthogonal\_at} method, which returns a \code{point} located at a given distance in the perpendicular direction, \code{ortho\_from} returns a full \code{line} object. This makes it suitable for further geometric constructions such as intersections, projections, or drawing perpendiculars.
1148
1149 \medskip
1150
1151 \texttt{Use this method when a perpendicular line is needed as a geometric object.}
1152
1153 Choose between \code{orthogonal\_at} and \code{ortho\_from} depending on whether you need a point or a line.
1154
1155 \begin{minipage}{.5\textwidth}
1156 \directlua{
1157 init_elements()
1158 z.A = point(1, 1)
1159 z.B = point(3, 2)
1160 L.AB = line(z.A, z.B)
1161 z.C = point(1, 3)
1162 L.CD = L.AB:ortho_from(z.C)
1163 z.D = L.CD.pb}
1164 \begin{center}
1165 \begin{tikzpicture}
1166 \tkzGetNodes
1167 \tkzDrawLines(A,B C,D)
1168 \tkzDrawPoints(A,...,D)
1169 \tkzLabelPoints(A,...,D)
1170 \end{tikzpicture}
1171 \end{center}
1172 \end{minipage}
1173 \begin{minipage}{.5\textwidth}
1174 \begin{tkzexample}[code only]
1175 \directlua{
1176 init_elements()
1177 z.A = point(1, 1)
1178 z.B = point(3, 2)
1179 L.AB = line(z.A, z.B)
1180 z.C = point(1, 3)
1181 L.CD = L.AB:ortho_from(z.C)
1182 z.D = L.CD.pb}
1183 \end{tkzexample}
1184 \end{minipage}
1185
1186 \subsubsection{Comparison between \texttt{orthogonal\_at} and \texttt{ortho\_from}}
1187
1188
1189 \begin{center}
1190 \bgroup
1191 \small
1192 \begin{tabular}{@{} l ll @{}}
1193 \toprule
1194 \textbf{Aspect} & \texttt{orthogonal\_at(pt, r)} & \texttt{ortho\_from(pt)} \\
1195 \midrule
1196 Return type & \code{point} & \code{line} \\
1197 Purpose & Perpendicular displacement & Perpendicular line \\
1198 Input & Point, scalar (optional) & Point \\
1199 Default scalar & \code{r = 1} & N/A \\
1200 Use case & Construct a perpendicular point & Build a perpendicular line \\
1201 \bottomrule
1202 \end{tabular}
1203 \egroup
1204 \end{center}
1205
1206 \subsubsection{Method \tkzMeth{line}{mediator()}} %(fold)
1207 \label{ssub:method_line_mediator}
1208
1209 In mathematical literature (e.g., \textit{MathWorld}), the \emph{mediator} of a segment—also known as the \emph{perpendicular bisector}—is defined as the line that passes through the midpoint of a segment and is perpendicular to it. It is sometimes called a \emph{mediating plane} in 3D geometry.
1210
1211 The term \emph{mediator} has historical roots, and was notably used by J. Neuberg (see Altshiller-Court, 1979, p.~298). In this package, I have chosen to adopt the French term \emph{médiatrice}, translated here as \code{mediator}.
1212
1213 \medskip
1214
1215 The method returns a new \code{line} object that is perpendicular to the original and passes through its midpoint.
1216
1217 \medskip
1218
1219 \texttt{Alias: } You may also call this method using the alternative names \code{perpendicular\_bisector()} or \code{bisector()}.
1220
1221 \vspace{1em}
1222 \begin{tkzexample}[latex=.5\textwidth]
1223 \directlua{
1224 init_elements()
1225 z.A = point(0,0)
1226 z.B = point(5,0)
1227 L.AB = line(z.A, z.B)
1228 L.med = L.AB:mediator()
1229 z.M = L.AB.mid
1230 z.x, z.y = L.med:get()}
1231 \begin{center}
1232 \begin{tikzpicture}
1233 \tkzGetNodes
1234 \tkzDrawLine(A,B)
1235 \tkzDrawSegments(x,y)
1236 \tkzDrawPoints(A,B,M)
1237 \tkzLabelPoints(A,B)
1238 \tkzLabelPoints[below left](x,y,M)
1239 \tkzMarkSegments(A,M M,B)
1240 \end{tikzpicture}
1241 \end{center}
1242 \end{tkzexample}
1243
1244
1245 \subsubsection{Method \tkzMeth{line}{collinear\_at\_distance(d)}}
1246 \label{ssub:method_line_collinear_at_distance}
1247
1248 \texttt{Description: } This method creates a new line parallel to the current one, at a signed distance \texttt{d}.
1249 The sign of \texttt{d} follows the usual convention:
1250 \texttt{d > 0} shifts the line to the \emph{left} of the oriented segment \(\overrightarrow{pa\,pb}\),
1251 and \texttt{d < 0} to the \emph{right}.
1252
1253 \medskip
1254 \texttt{Syntax: } \verb|L' = L:collinear_at_distance(d)|
1255
1256 \medskip
1257 \texttt{Arguments: } \texttt{d} — signed offset distance (real number, same unit as coordinates).
1258
1259 \medskip
1260 \texttt{Return value: }
1261
1262 A new \tkzname{line} object parallel to \texttt{L} at distance \texttt{d}.
1263
1264 \medskip
1265 \texttt{Example usage: }
1266
1267 \begin{tkzexample}[latex=.4\textwidth]
1268 \directlua{
1269 z.A = point(0, 0)
1270 z.B = point(5, 2)
1271 L.AB = line (z.A, z.B)
1272 L.n = line(collinear_at_distance_(z.A, z.B, -1))
1273 z.D, z.E = L.n:get()}
1274 \begin{tikzpicture}[gridded,scale=.5]
1275 \tkzGetNodes
1276 \tkzDrawLines[blue](A,B)
1277 \tkzDrawLines[red](D,E)
1278 \tkzDrawPoints[red,size=4](A,B,D,E)
1279 \tkzLabelPoints[red](A,B,D,E)
1280 \end{tikzpicture}
1281 \end{tkzexample}
1282
1283
1284
1285 \subsubsection{Method \tkzMeth{line}{swap\_line}}
1286 \label{ssub:method_line_swap__line}
1287
1288 \texttt{Purpose: }This method is not intended for frequent use, but it can be useful in specific contexts.
1289 When a line is created, it is defined by two points—\code{pa} and \code{pb}—which determine the direction of the line. In certain geometric constructions (notably involving conics), the orientation of the line can affect the outcome of computations or methods.
1290
1291 \medskip
1292 The \code{swap\_line()} method returns a new \code{line} object with the order of the defining points reversed, effectively reversing the direction of the line.
1293
1294 \medskip
1295
1296 This is particularly relevant when direction-sensitive operations (e.g., projections, asymptotes, or oriented intersection tests) are involved.
1297
1298 \vspace{1em}
1299 \begin{tkzexample}[latex=7cm]
1300 \directlua{
1301 init_elements()
1302 z.A = point(0, 0)
1303 z.B = point(2, -1)
1304 L.dir = line(z.A, z.B)
1305 L.dir = L.dir:swap_line()
1306 z.a = L.dir.pa
1307 z.b = L.dir.pb}
1308 \begin{tikzpicture}
1309 \tkzGetNodes
1310 \tkzDrawSegments[cyan,thick,->](a,b)
1311 \tkzLabelPoints[below](A,B)
1312 \end{tikzpicture}
1313 \end{tkzexample}
1314
1315 \subsection{Returns a triangle}
1316
1317 \subsubsection{Method \tkzMeth{line}{equilateral(<'swap'>)}}
1318 \label{ssub:method_line_equilateral}
1319
1320 This method constructs an equilateral triangle using the segment defined by the line as its base.
1321
1322 \medskip
1323
1324 The triangle has three equal sides, and its base is the segment from \code{pa} to \code{pb}. The construction respects the orientation of the base.
1325
1326 \begin{itemize}
1327 \item By default, the triangle is built in the \emph{direct (counterclockwise)} orientation: the triangle has vertices $A$, $B$, $C$ where $AB$ is the base.
1328 \item If the optional argument \code{"swap"} is provided, the orientation is reversed: the triangle becomes $A$, $B$, $C$ in indirect (clockwise) order.
1329 \end{itemize}
1330
1331 \medskip
1332
1333 This method returns a \code{triangle} object.
1334
1335
1336 \vspace{1em}
1337 \begin{minipage}{.5\textwidth}
1338 \directlua{
1339 init_elements()
1340 z.A = point(0,0)
1341 z.B = point(4,0)
1342 L.AB = line(z.A, z.B)
1343 T.ABC = L.AB:equilateral()
1344 z.C = T.ABC.pc}
1345 \begin{center}
1346 \begin{tikzpicture}
1347 \tkzGetNodes
1348 \tkzDrawLine(A,B)
1349 \tkzDrawPolygon(A,B,C)
1350 \tkzMarkSegments(A,B B,C C,A)
1351 \tkzDrawPoints(A,B,C)
1352 \tkzMarkAngles(B,A,C C,B,A A,C,B)
1353 \tkzLabelPoints(A,B)
1354 \tkzLabelPoints[above](C)
1355 \end{tikzpicture}
1356 \end{center}
1357 \end{minipage}
1358 \begin{minipage}{.5\textwidth}
1359 \begin{tkzexample}[code only]
1360 \directlua{
1361 init_elements()
1362 z.A = point(0,0)
1363 z.B = point(4,0)
1364 L.AB = line(z.A, z.B)
1365 T.ABC = L.AB:equilateral()
1366 z.C = T.ABC.pc}
1367 \end{tkzexample}
1368 \end{minipage}
1369
1370 \subsubsection{Method \tkzMeth{line}{isosceles(d, <'swap'>)}}
1371 \label{ssub:method_line_isosceles}
1372
1373 This method constructs an isosceles triangle having the segment defined by the line as its base.
1374
1375 \medskip
1376 The argument \code{d} specifies the length of the two equal sides extending from each endpoint of the base. The triangle is constructed in the default orientation determined by the direction from \code{pa} to \code{pb}.
1377
1378 \medskip
1379
1380 If the optional argument \meta{"swap"} is provided, the triangle is constructed in the opposite orientation (i.e., the apex is placed on the other side of the base).
1381
1382 \medskip
1383
1384 The method returns a \code{triangle} object.
1385
1386 \vspace{1em}
1387 \begin{minipage}{.5\textwidth}
1388 \directlua{
1389 init_elements()
1390 z.a = point(0, 0)
1391 z.b = point(3, 0)
1392 L.ab = line(z.a, z.b)
1393 T.abc = L.ab:isosceles(4)
1394 z.c = T.abc.pc}
1395 \begin{center}
1396 \begin{tikzpicture}
1397 \tkzGetNodes
1398 \tkzDrawPolygons(a,b,c)
1399 \tkzDrawPoints(a,b,c)
1400 \tkzLabelPoints[above](c)
1401 \tkzLabelPoints(a, b)
1402 \tkzLabelSegment[right](b,c){$4$}
1403 \tkzLabelSegment[left](a,c){$4$}
1404 \end{tikzpicture}
1405 \end{center}
1406 \end{minipage}
1407 \begin{minipage}{.5\textwidth}
1408 \begin{tkzexample}[code only]
1409 \directlua{
1410 init_elements()
1411 z.a = point(1, 2)
1412 z.b = point(3, 1)
1413 L.ab = line(z.a, z.b)
1414 T.abc = L.ab:isosceles(4)
1415 z.c = T.abc.pc}
1416 \end{tkzexample}
1417 \end{minipage}
1418
1419 \subsubsection{Method \tkzMeth{line}{school(<'swap'>)}}
1420 \label{ssub:method_imeth_line_school_swap}
1421 The \code{school} triangle is a right triangle with angles measuring $30^\circ$, $60^\circ$, and $90^\circ$—commonly used in elementary geometric constructions.
1422
1423 \medskip
1424
1425 By default, the $30^\circ$ angle is at the first point (\code{pa}) of the line, and the $60^\circ$ angle is at the second point (\code{pb}). Using the optional argument \meta{"swap"} reverses this placement, exchanging the two base angles.
1426
1427 \medskip
1428
1429 To reverse the triangle’s orientation (i.e., construct it in the indirect direction), simply reverse the order of the points defining the line, for example:
1430 \code{L.AB = line(z.B, z.A)}.
1431
1432 \vspace{1em}
1433 \begin{minipage}{.5\textwidth}
1434 \directlua{
1435 init_elements()
1436 z.A = point(0, 0)
1437 z.B = point(4, 0)
1438 L.AB = line(z.A, z.B)
1439 T.ABC = L.AB:school()
1440 z.C = T.ABC.pc}
1441 \begin{center}
1442 \begin{tikzpicture}
1443 \tkzGetNodes
1444 \tkzDrawPolygons(A,B,C)
1445 \tkzDrawPoints(A,B,C)
1446 \tkzLabelPoints(A,B)
1447 \tkzLabelPoints[above](C)
1448 \tkzMarkAngle[red](C,B,A)
1449 \tkzMarkAngle[red](B,A,C)
1450 \tkzMarkAngle[red](A,C,B)
1451 \tkzLabelAngle[red,
1452 pos=.5](A,C,B){$\scriptstyle\pi/2$}
1453 \tkzLabelAngle[red,
1454 pos=.7](B,A,C){$\scriptstyle\pi/6$}
1455 \tkzLabelAngle[red,
1456 pos=.5](C,B,A){$\scriptstyle\pi/3$}
1457 \end{tikzpicture}
1458 \end{center}
1459
1460 \end{minipage}
1461 \begin{minipage}{.5\textwidth}
1462 \begin{tkzexample}[code only]
1463 \directlua{
1464 init_elements()
1465 z.A = point(0, 0)
1466 z.B = point(4, 0)
1467 L.AB = line(z.A, z.B)
1468 T.ABC = L.AB:school()
1469 z.C = T.ABC.pc}
1470 \end{tkzexample}
1471 \end{minipage}
1472
1473 \subsubsection{Method \tkzMeth{line}{half(<'swap'>)}}
1474 \label{ssub:method_imeth_line_half_swap}
1475
1476 This method constructs a right triangle in which the two sides adjacent to the right angle are in the ratio $1:2$.
1477
1478 \medskip
1479
1480 By default, the right angle is located at the first point of the line (\code{pa}). If the optional argument \meta{"swap"} is provided, the right angle is placed at the second point (\code{pb}).
1481
1482 \medskip
1483
1484 This type of triangle is useful for constructing simple geometric configurations or illustrating special triangle cases.
1485
1486 \vspace{1em}
1487 \begin{minipage}{.5\textwidth}
1488 \directlua{
1489 init_elements()
1490 z.A = point(0, 0)
1491 z.B = point(4, 0)
1492 L.AB = line(z.A, z.B)
1493 T.ABC = L.AB:half('swap')
1494 z.C = T.ABC.pc}
1495 \begin{center}
1496 \begin{tikzpicture}
1497 \tkzGetNodes
1498 \tkzDrawPolygons(A,B,C)
1499 \tkzDrawPoints(A,B,C)
1500 \tkzLabelPoints(A,B)
1501 \tkzLabelPoints[above](C)
1502 \tkzLabelAngle[red,
1503 pos=.5](B,A,C){$\scriptstyle\pi/2$}
1504 \tkzLabelSegment(A,B){$AB = 2 AC$}
1505 \end{tikzpicture}
1506 \end{center}
1507
1508 \end{minipage}
1509 \begin{minipage}{.5\textwidth}
1510 \begin{tkzexample}[code only]
1511 \directlua{
1512 init_elements()
1513 z.A = point(0, 0)
1514 z.B = point(4, 0)
1515 L.AB = line(z.A, z.B)
1516 T.ABC = L.AB:half('swap')
1517 z.C = T.ABC.pc}
1518 \end{tkzexample}
1519 \end{minipage}
1520
1521 \subsubsection{Method \tkzMeth{line}{two\_angles(an, an)}}
1522 \label{ssub:triangle_with_two__angles}
1523
1524 This method constructs a triangle by specifying two angles located at each endpoint of the given segment. The triangle is completed by determining the third vertex so that the sum of the interior angles is $180^\circ$.
1525
1526 \medskip
1527
1528 The two given angles are applied at the endpoints \code{pa} and \code{pb} of the line. The resulting triangle is determined by extending the sides from these angles until they meet.
1529
1530 \medskip
1531
1532 This method corresponds to the classical ASA construction (\textit{Angle–Side–Angle}) and may also be called using the alternative names \code{asa} or \code{a\_a}.
1533
1534 \vspace{1em}
1535
1536 \begin{minipage}{.35\textwidth}
1537 \directlua{
1538 init_elements()
1539 z.A = point(0, 0)
1540 z.B = point(4, 0)
1541 L.AB = line(z.A, z.B)
1542 T.ABC = L.AB:two_angles(math.pi / 6,2 * math.pi / 5)
1543 z.C = T.ABC.pc}
1544 \begin{center}
1545 \begin{tikzpicture}
1546 \tkzGetNodes
1547 \tkzDrawPolygons(A,B,C)
1548 \tkzDrawPoints(A,B,C)
1549 \tkzLabelPoints(A,B)
1550 \tkzLabelPoints[above](C)
1551 \tkzMarkAngle[red](C,B,A)
1552 \tkzMarkAngle[red](B,A,C)
1553 \tkzLabelAngle[red,
1554 pos=1.3](C,B,A){$\scriptstyle2\pi/5$}
1555 \tkzLabelAngle[red,
1556 pos=1.3](B,A,C){$\scriptstyle\pi/6$}
1557 \end{tikzpicture}
1558 \end{center}
1559 \end{minipage}
1560 \begin{minipage}{.65\textwidth}
1561 \begin{tkzexample}[code only]
1562 \directlua{
1563 init_elements()
1564 z.A = point(0, 0)
1565 z.B = point(4, 0)
1566 L.AB = line(z.A, z.B)
1567 T.ABC = L.AB:two_angles(math.pi / 6,2 * math.pi / 5)
1568 z.C = T.ABC.pc}
1569 \end{tkzexample}
1570 \end{minipage}
1571
1572 \subsubsection{Method \tkzMeth{line}{s\_s(d, d)}}
1573 \label{ssub:triangle_with_three_given_sides}
1574
1575 This method constructs a triangle given the lengths of its three sides: the base and the two sides adjacent to it.
1576
1577 \medskip
1578
1579 The base of the triangle is defined by the line object (e.g., \code{L.AB}), which determines the segment between \code{pa} and \code{pb}. The two arguments \code{d} represent the lengths of the remaining sides.
1580
1581 \medskip
1582
1583 This construction corresponds to the classical \code{SSS} configuration (\textit{Side–Side–Side}), and the method may also be called using the aliases \code{s\_s} or \code{sss}.
1584
1585 \vspace{1em}
1586
1587 \begin{minipage}{.5\textwidth}
1588 \directlua{
1589 init_elements()
1590 z.A = point(0, 0)
1591 z.B = point(5, 0)
1592 L.AB = line(z.A, z.B)
1593 T.ABC = L.AB:s_s(3, 4)
1594 z.C = T.ABC.pc}
1595 \begin{center}
1596 \begin{tikzpicture}[gridded]
1597 \tkzGetNodes
1598 \tkzDrawPolygons(A,B,C)
1599 \tkzDrawPoints(A,B,C)
1600 \tkzLabelPoints(A,B)
1601 \tkzLabelPoints[above](C)
1602 \end{tikzpicture}
1603 \end{center}
1604 \end{minipage}
1605 \begin{minipage}{.5\textwidth}
1606 \begin{tkzexample}[code only]
1607 \directlua{
1608 init_elements()
1609 z.A = point(0, 0)
1610 z.B = point(5, 0)
1611 L.AB = line(z.A, z.B)
1612 T.ABC = L.AB:s_s(3, 4)
1613 z.C = T.ABC.pc}
1614 \end{tkzexample}
1615 \end{minipage}
1616
1617 \subsubsection{Method \tkzMeth{line}{sa\_(d, an, <'swap'>)}}
1618 \label{ssub:_line_sas_d_an}
1619
1620 This method constructs a triangle from a given base (the line), a side length, and the angle between that side and the base.
1621
1622 \medskip
1623
1624 It corresponds to the classical \code{SAS} configuration (\textit{Side–Angle–Side}). The side of length \code{d} is placed at the first point \code{pa} of the base, and the angle \code{an} (in degrees) is formed between this side and the base.
1625
1626 \medskip
1627
1628 If the optional argument \meta{"swap"} is provided, the side and angle are instead applied from the second point \code{pb}, effectively mirroring the triangle across the base.
1629
1630 \vspace{1em}
1631 \directlua{
1632 init_elements()
1633 z.A = point(0, 0)
1634 z.B = point(5, 0)
1635 L.AB = line(z.A, z.B)
1636 T.ABD = L.AB:sa_(3, tkz.tau / 5)
1637 z.D = T.ABD.pc}
1638 \begin{center}
1639 \begin{tikzpicture}[gridded]
1640 \tkzGetNodes
1641 \tkzDrawPolygons(A,B,D)
1642 \tkzDrawPoints(A,B,D)
1643 \tkzLabelPoints(A,B)
1644 \tkzLabelPoints[above](D)
1645 \end{tikzpicture}
1646 \end{center}
1647
1648 \subsubsection{Method \tkzMeth{line}{\_as(d, an,<'swap'>)}}
1649 \label{ssub:_line__as_d_an_swap}
1650
1651 This method is the counterpart of \code{sa\_}. It constructs a triangle using a given base (the line), a side of length \code{d}, and the angle \code{an} adjacent to that side, but this time measured from the second point \code{pb} of the base.
1652
1653 \medskip
1654
1655 The construction still corresponds to the classical \code{SAS} configuration (\textit{Side–Angle–Side}), but applied in reverse order from the base's endpoint.
1656
1657 \medskip
1658
1659 If the optional argument \meta{"swap"} is provided, the triangle is built in indirect (clockwise) orientation, which may be useful for constructing mirrored configurations.
1660
1661 \subsubsection{Method \tkzMeth{line}{s\_a(d, an, <'swap'>)}}
1662 \label{ssub:_line_sa}
1663
1664 This method constructs a triangle from a given base (the line), a side of length \code{d}, and an angle \code{an} opposite that side.
1665
1666 \medskip
1667
1668 The construction corresponds to the classical \code{SSA} configuration (\emph{Side–Side–Angle}), which is known to be ambiguous: depending on the values of the side and angle, the result may be:
1669
1670 \begin{itemize}
1671 \item no triangle (invalid configuration),
1672 \item exactly one triangle,
1673 \item or two possible triangles.
1674 \end{itemize}
1675
1676 \medskip
1677
1678 When two triangles are possible, the method returns the one with the larger angle at the base by default. If the optional argument \meta{"swap"} is provided, the method returns the second solution.
1679
1680 \vspace{1em}
1681
1682 \directlua{
1683 init_elements()
1684 z.A = point(0, 0)
1685 z.B = point(5, 0)
1686 L.AB = line(z.A, z.B)
1687 T.ABE = L.AB:s_a(4, math.pi / 5)
1688 z.E = T.ABE.pc
1689 T.ABD = L.AB:s_a(4, math.pi / 5,'swap')
1690 z.D = T.ABD.pc
1691 }
1692 \begin{center}
1693 \begin{tikzpicture}[gridded]
1694 \tkzGetNodes
1695 \tkzDrawPolygons(A,B,E A,B,D)
1696 \tkzDrawPoints(A,B,E,D)
1697 \tkzLabelPoints(A,B)
1698 \tkzLabelPoints[above](E,D)
1699 \end{tikzpicture}
1700 \end{center}
1701
1702 \subsubsection{Method \tkzMeth{line}{a\_s(d,an,<'swap'>)}}
1703 \label{ssub:_line_a__s_d_an_swap}
1704
1705 \subsubsection{Summary of triangle construction methods from a line}
1706
1707 \begin{center}
1708 \bgroup
1709 \small
1710 \begin{tabular}{@{} llll @{}}
1711 \toprule
1712 \smallbf{Method} & \smallbf{Type} & \smallbf{Parameters} & \smallbf{Angle configuration} \\
1713 \midrule
1714 \code{equilateral()} & Equilateral & none & $60^\circ$ – $60^\circ$ – $60^\circ$ \\
1715 \code{isosceles(d)} & Isosceles & one side & Two equal angles \\
1716 \code{school()} & Right & none & $30^\circ$ – $60^\circ$ – $90^\circ$ \\
1717 \code{half()} & Right & none & One angle with $\tan\theta = 1/2$ \\
1718 \code{two\_angles(a,b)}& ASA & two angles & Two angles at endpoints \\
1719 \code{s\_s(d,d)} & SSS & two sides & Three known sides \\
1720 \code{sa\_(d,an)} & SAS & side + angle at \code{pa} & Included angle at first point \\
1721 \code{\_as(d,an)} & SAS & side + angle at \code{pb} & Included angle at second point \\
1722 \code{s\_a(d,an)} & SSA & side + opposite angle & Possible ambiguity \\
1723 \bottomrule
1724 \end{tabular}
1725 \egroup
1726 \end{center}
1727
1728 \subsection{Returns a sacred triangle}
1729
1730 The names attributed to these triangles are traditional or symbolic and may differ from those used in standard mathematical literature.
1731
1732 \vspace{1em}
1733 \begin{tabular}{@{}ll@{}}
1734 \toprule
1735 \smallbf{Name (Method)} & \smallbf{Definition / Properties} \\
1736 \midrule
1737 \tkzMeth{line}{gold()} &
1738 Right triangle with $c/b = \sqrt{\varphi}$; half of the golden rectangle \\
1739 \addlinespace
1740 \tkzMeth{line}{golden()} &
1741 Isosceles triangle with $b/c = \varphi$, angles $\alpha = \beta = \dfrac{2\pi}{5}$;\\
1742 & Also called: sublime triangle, Euclid's triangle \\
1743 \addlinespace
1744 \tkzMeth{line}{golden\_gnomon()} &
1745 Isosceles triangle with $b/c = 1/\varphi$, angles $\alpha = \beta = \dfrac{\pi}{5}$ \\
1746 \addlinespace
1747 \tkzMeth{line}{pythagoras()} &
1748 Right triangle with sides $a = 5k$, $b = 4k$, $c = 3k$;\\
1749 & Also known as the Egyptian or Isis triangle \\
1750 \bottomrule
1751 \end{tabular}
1752
1753
1754
1755 \subsubsection{Method \tkzMeth{line}{gold()}}
1756 \label{ssub:method_line_gold}
1757
1758 This method constructs a right triangle in which the ratio of the lengths of the two sides adjacent to the right angle is equal to~$\varphi$, the golden ratio:
1759
1760 \[
1761 \dfrac{c}{b} = \sqrt{\varphi}
1762 \]
1763
1764
1765 This triangle corresponds to half of a golden rectangle.
1766
1767 \vspace{1em}
1768 \begin{minipage}{.5\textwidth}
1769 \directlua{
1770 init_elements()
1771 z.A = point(0, 0)
1772 z.B = point(5, 0)
1773 L.AB = line(z.A, z.B)
1774 T.ABC = L.AB:gold()
1775 z.C = T.ABC.pc}
1776 \begin{center}
1777 \begin{tikzpicture}[gridded]
1778 \tkzGetNodes
1779 \tkzDrawPolygons(A,B,C)
1780 \tkzDrawPoints(A,B,C)
1781 \tkzLabelPoints(A,B)
1782 \tkzLabelPoints[above](C)
1783 \end{tikzpicture}
1784 \end{center}
1785 \end{minipage}
1786 \begin{minipage}{.5\textwidth}
1787 \begin{tkzexample}[code only]
1788 \directlua{
1789 init_elements()
1790 z.A = point(0, 0)
1791 z.B = point(5, 0)
1792 L.AB = line(z.A, z.B)
1793 T.ABC = L.AB:gold()
1794 z.C = T.ABC.pc}
1795 \end{tkzexample}
1796 \end{minipage}
1797
1798 \subsubsection{Method \tkzMeth{line}{golden()}}
1799 \label{ssub:method_line_golden}
1800
1801 A golden triangle—also known as a \emph{sublime triangle}—is an isosceles triangle in which the equal sides are in the golden ratio $\varphi$ to the base.
1802
1803 \medskip
1804
1805 In this construction, the ratio of a duplicated side $b$ to the base $c$ satisfies:
1806
1807 \[
1808 \dfrac{b}{c} = \varphi
1809 \]
1810
1811
1812 This triangle appears in many classical constructions, notably in pentagonal geometry and Euclidean aesthetics.
1813
1814 \vspace{1em}
1815 \begin{minipage}{.5\textwidth}
1816 \directlua{
1817 init_elements()
1818 z.A = point(0, 0)
1819 z.B = point(2, 0)
1820 L.AB = line(z.A, z.B)
1821 T.ABC = L.AB:golden()
1822 z.C = T.ABC.pc}
1823 \begin{center}
1824 \begin{tikzpicture}[gridded]
1825 \tkzGetNodes
1826 \tkzDrawPolygons(A,B,C)
1827 \tkzDrawPoints(A,B,C)
1828 \tkzLabelPoints(A,B)
1829 \tkzLabelPoints[above](C)
1830 \tkzLabelSegment[above](A,C){$b$}
1831 \tkzLabelSegment(A,B){$c$}
1832 \tkzLabelAngle[red,
1833 pos=.5](C,B,A){$\scriptstyle 2\pi/5$}
1834 \end{tikzpicture}
1835 \end{center}
1836 \end{minipage}
1837 \begin{minipage}{.5\textwidth}
1838 \begin{tkzexample}[code only]
1839 \directlua{
1840 init_elements()
1841 z.A = point(0, 0)
1842 z.B = point(2, 0)
1843 L.AB = line(z.A, z.B)
1844 T.ABC = L.AB:golden()
1845 z.C = T.ABC.pc}
1846 \end{tkzexample}
1847 \end{minipage}
1848
1849 \subsubsection{Method \tkzMeth{line}{golden\_gnomon()}}
1850 \label{ssub:method_line_golden__gnomon}
1851
1852 The \code{golden\_gnomon}, also called the \emph{divine triangle}, is an obtuse isosceles triangle in which the ratio of the side length to the base is equal to the inverse of the golden ratio:
1853
1854 \[
1855 \dfrac{b}{c} = \frac{1}{\varphi} = \varphi - 1
1856 \]
1857
1858
1859 This triangle has two angles measuring $36^\circ$ and one angle of $108^\circ$. It can be constructed geometrically from a regular pentagon and frequently appears in golden ratio-based constructions.
1860
1861 \vspace{1em}
1862
1863 \begin{minipage}{.5\textwidth}
1864 \directlua{
1865 init_elements()
1866 z.A = point(0, 0)
1867 z.B = point(5, 0)
1868 L.AB = line(z.A, z.B)
1869 T.ABC = L.AB:divine()
1870 z.C = T.ABC.pc}
1871 \begin{center}
1872 \begin{tikzpicture}[gridded]
1873 \tkzGetNodes
1874 \tkzDrawPolygons(A,B,C)
1875 \tkzDrawPoints(A,B,C)
1876 \tkzLabelPoints(A,B)
1877 \tkzLabelPoints[above](C)
1878 \tkzLabelSegment[above](A,C){$b$}
1879 \tkzLabelSegment(A,B){$c$}
1880 \tkzLabelAngle[red,
1881 pos=.5](C,B,A){$\scriptstyle \pi/5$}
1882 \end{tikzpicture}
1883 \end{center}
1884 \end{minipage}
1885 \begin{minipage}{.5\textwidth}
1886 \begin{tkzexample}[code only]
1887 \directlua{
1888 init_elements()
1889 z.A = point(0, 0)
1890 z.B = point(5, 0)
1891 L.AB = line(z.A, z.B)
1892 T.ABC = L.AB:divine()
1893 z.C = T.ABC.pc}
1894 \end{tkzexample}
1895 \end{minipage}
1896
1897 \subsubsection{Method \tkzMeth{line}{pythagoras()}}
1898 \label{ssub:_line_egyptian}
1899
1900 This method constructs the classical right triangle whose side lengths are in the ratio $3\mathbin{:}4\mathbin{:}5$.
1901
1902 \medskip
1903
1904 Also known as the \emph{Egyptian triangle} or \emph{Isis triangle}, it is a Pythagorean triangle with integer side proportions:
1905
1906 \[
1907 a = 3k,\quad b = 4k,\quad c = 5k
1908 \]
1909
1910
1911 It is one of the most fundamental triangles in Euclidean geometry and appears in many historical constructions.
1912
1913 \vspace{1em}
1914
1915 \begin{minipage}{.5\textwidth}
1916 \directlua{
1917 init_elements()
1918 z.A = point(0, 0)
1919 z.B = point(4, 0)
1920 L.AB = line(z.A, z.B)
1921 T.ABC = L.AB:egyptian()
1922 z.C = T.ABC.pc}
1923 \begin{center}
1924 \begin{tikzpicture}[gridded]
1925 \tkzGetNodes
1926 \tkzDrawPolygons(A,B,C)
1927 \tkzDrawPoints(A,B,C)
1928 \tkzLabelPoints(A,B)
1929 \tkzLabelPoints[above](C)
1930 \tkzLabelAngle[red,
1931 pos=.5](C,B,A){$\scriptstyle \pi/2$}
1932 \end{tikzpicture}
1933 \end{center}
1934 \end{minipage}
1935 \begin{minipage}{.5\textwidth}
1936 \begin{tkzexample}[code only]
1937 \directlua{
1938 init_elements()
1939 z.A = point(0, 0)
1940 z.B = point(5, 0)
1941 L.AB = line(z.A, z.B)
1942 T.ABC = L.AB:egyptian()
1943 z.C = T.ABC.pc}
1944 \end{tkzexample}
1945 \end{minipage}
1946
1947 \subsection{Returns a circle}
1948
1949
1950
1951 \subsubsection{Method \tkzMeth{line}{apollonius(d)}}
1952 \label{ssub:apollonius_circle_ma_mb_k}
1953
1954 Given two points $A$ and $B$, this method constructs the Apollonius circle: the locus of points $M$ such that the ratio of distances to $A$ and $B$ is constant:
1955
1956 \[
1957 \dfrac{MA}{MB} = d
1958 \]
1959
1960
1961 The resulting object is a circle that does not pass through $A$ or $B$ (unless $d = 1$, in which case it becomes the perpendicular bisector of segment $[AB]$). The method returns a \code{circle} object.
1962
1963 \vspace{1em}
1964
1965 \begin{tkzexample}[vbox]
1966 \directlua{
1967 init_elements()
1968 z.A = point(0, 0)
1969 z.B = point(6, 0)
1970 L.AB = line(z.A, z.B)
1971 C.apo = L.AB:apollonius(2)
1972 z.O,z.C = C.apo:get()
1973 z.D = C.apo:antipode(z.C)
1974 z.P = C.apo:point(0.30)}
1975
1976 \begin{center}
1977 \begin{tikzpicture}[scale=.8]
1978 \tkzGetNodes
1979 \tkzFillCircle[blue!20,opacity=.2](O,C)
1980 \tkzDrawCircle[blue!50!black](O,C)
1981 \tkzDrawPoints(A,B,O,C,D,P)
1982 \tkzDrawSegments[orange](P,A P,B P,D B,D P,C)
1983 \tkzDrawSegments[red](A,C)
1984 \tkzDrawPoints(A,B)
1985 \tkzLabelCircle[draw,fill=green!10,%
1986 text width=3cm,text centered,left=24pt](O,D)(60)%
1987 {$CA/CB=2$\\$PA/PB=2$\\$DA/DB=2$}
1988 \tkzLabelPoints[below right](A,B,O,C,D)
1989 \tkzLabelPoints[above](P)
1990 \tkzMarkRightAngle[opacity=.3,fill=lightgray](D,P,C)
1991 \tkzMarkAngles[mark=||](A,P,D D,P,B)
1992 \end{tikzpicture}
1993 \end{center}
1994 \end{tkzexample}
1995
1996
1997 Remark: |\tkzUseLua{tkz.length(z.P,z.A)/tkz.length(z.P,z.B)}| = \tkzUseLua{tkz.length(z.P,z.A)/tkz.length(z.P,z.B)}
1998
1999 \subsubsection{Method \tkzMeth{line}{LPP}(p, p)}
2000 \label{ssub:c_l_pp}
2001
2002 This method is presented in the document \tkzname{Euclidean Geometry} presented in \href{http://altermundus.fr}{altermundus.fr}.
2003
2004 \begin{tkzexample}[latex=.4\textwidth]
2005 \directlua{
2006 init_elements()
2007 z.A = point(0, 0)
2008 z.B = point(6, 0)
2009 z.M = point(1, 1)
2010 z.N = point(2, 5)
2011 L.AB = line(z.A, z.B)
2012 PA.center,
2013 PA.through, n = L.AB:LPP(z.M, z.N)
2014 tkz.nodes_from_paths(PA.center,
2015 PA.through, "O", "T")
2016 }
2017
2018 \begin{tikzpicture}[scale = .4]
2019 \tkzGetNodes
2020 \tkzDrawLines(A,B M,N)
2021 \tkzDrawCircles(O1,T1 O2,T2)
2022 \tkzDrawPoints(A,B,M,N)
2023 \tkzLabelPoints(A,B,M,N)
2024 \end{tikzpicture}
2025 \end{tkzexample}
2026
2027 \subsubsection{Method \tkzMeth{line}{LLP}(L, p)}
2028 \label{ssub:method_c__ll__p}
2029
2030 This method is presented in the document \tkzname{Euclidean Geometry} presented in \href{http://altermundus.fr}{altermundus.fr}.
2031
2032
2033 \begin{tkzexample}[latex=.5\textwidth]
2034 \directlua{
2035 init_elements()
2036 z.A = point(-1, 2)
2037 z.B = point(2, -3)
2038 z.C = point(-1, -3)
2039 z.D = point(2, 1)
2040 L.AB = line(z.A, z.B)
2041 L.CD = line(z.C, z.D)
2042 z.S = intersection(L.AB, L.CD)
2043 L.SI = tkz.bisector(z.S, z.A, z.D)
2044 z.P = L.SI:point(-1)
2045 local centers,
2046 throughs, n = L.AB:LLP(L.CD, z.P)
2047 tkz.nodes_from_paths(centers, throughs)
2048 }
2049 \begin{center}
2050 \begin{tikzpicture}
2051 \tkzGetNodes
2052 \tkzDrawLines[red](A,B C,D)
2053 \tkzDrawCircles[blue](w1,t1 w2,t2)
2054 \tkzDrawPoints(A,B,C,D,P,w1,t1,w2,t2)
2055 \tkzLabelPoints(A,B,C,D,P)
2056 \end{tikzpicture}
2057 \end{center}
2058 \end{tkzexample}
2059
2060 %====================================================================
2061 \subsubsection{Method \tkzMeth{line}{LLL}(L1,L2[,which])}
2062 %====================================================================
2063 \label{ssub:method_LLL}
2064
2065 This method is presented in the document \tkzname{Euclidean Geometry} presented in \href{http://altermundus.fr}{altermundus.fr}.
2066
2067 \begin{tkzexample}[latex=.5\textwidth]
2068 \directlua{
2069 init_elements()
2070 z.A = point(0, 0)
2071 z.B = point(6, 0)
2072 z.C = point(4.5, 6)
2073 T.ABC = triangle(z.A, z.B, z.C)
2074 L.AB = line(z.A, z.B)
2075 L.AC = line(z.A, z.C)
2076 L.med = L.AB:mediator ()
2077 z.M = L.AB.mid
2078 z.x, z.y = get_points(L.med)
2079 z.H = L.AB:projection(z.C)
2080 L.ortho = L.AB:orthogonal_from(z.C)
2081 PA.center,
2082 PA.through = L.AC:LLL(L.med, L.ortho)
2083 z.w = PA.center:get(1)
2084 z.t = PA.through:get(1)
2085 PA.center,
2086 PA.through = L.AB:LLL(L.AC, T.ABC.bc)
2087 z.o = PA.center:get(1)
2088 z.h = PA.through:get(1)}
2089 \begin{center}
2090 \begin{tikzpicture}
2091 \tkzGetNodes
2092 \tkzDrawLines(A,B A,C B,C)
2093 \tkzDrawCircles(w,t o,h)
2094 \tkzDrawPoints(A,B,C)
2095 \tkzLabelPoints(A,B,C)
2096 \end{tikzpicture}
2097 \end{center}
2098 \end{tkzexample}
2099
2100 \subsection{The result is a square}
2101
2102
2103 \subsubsection{Method \tkzMeth{line}{square(<'swap'>)}}
2104 \label{ssub:method_line_square}
2105
2106 This method constructs a square using the segment defined by the line as one of its sides. The resulting square shares the segment $[AB]$ as a base and constructs the remaining two vertices so that all angles are right angles and all sides are equal in length.
2107
2108 \medskip
2109
2110 By default, the square is built in the direct orientation from $A$ to $B$. If the optional argument \meta{"swap"} is provided, the square is built on the opposite side, reversing its orientation.
2111
2112 \medskip
2113
2114 The result is a \code{square} object, and its vertices can be accessed using the \code{get()} method.
2115
2116 \vspace{1em}
2117
2118 \begin{tkzexample}[latex=.5\textwidth]
2119 \directlua{
2120 init_elements()
2121 z.A = point(0, 0)
2122 z.B = point(-3, 2 )
2123 L.AB = line(z.A, z.B)
2124 S.AB = L.AB:square("swap")
2125 _,_,z.C,z.D = S.AB:get()}
2126
2127 \begin{tikzpicture}
2128 \tkzGetNodes
2129 \tkzDrawPolygon(A,...,D)
2130 \tkzDrawPoints(A,...,D)
2131 \tkzLabelPoints(A,...,D)
2132 \end{tikzpicture}
2133 \end{tkzexample}
2134
2135 \subsection{Transformations: the result is an object}
2136 \label{sub:the_result_is_an_object}
2137
2138 This section presents geometric transformations whose result is a new geometric object. The nature of the result depends on both the transformation and the type of argument passed.
2139
2140
2141 \subsubsection{Method \tkzMeth{line}{projection(obj)}}
2142 \label{ssub:example_projection_of_several_points}
2143
2144 This method projects one or more points orthogonally onto the line.
2145
2146 \medskip
2147
2148 The argument \code{obj} may be:
2149 \begin{itemize}
2150 \item a single point object (e.g., \code{z.P}),
2151 \item a list (Lua table) of point objects.
2152 \end{itemize}
2153
2154
2155 The result is either:
2156 \begin{itemize}
2157 \item a single projected point, if the input is a point,
2158 \item a table of projected points, if the input is a list.
2159 \end{itemize}
2160
2161 \medskip
2162
2163 This method is useful for constructing foots of perpendiculars or projecting configurations onto a supporting line.
2164
2165 \vspace{1em}
2166
2167 \begin{tkzexample}[latex=.5\textwidth]
2168 \directlua{
2169 init_elements()
2170 z.a = point(0, 0)
2171 z.b = point(4, 1)
2172 z.c = point(2, 5)
2173 z.d = point(5, 2)
2174 L.ab = line(z.a, z.b)
2175 z.cp, z.dp = L.ab:projection(z.c, z.d)}
2176 \begin{center}
2177 \begin{tikzpicture}[scale = .8]
2178 \tkzGetNodes
2179 \tkzDrawLines(a,b c,c' d,d')
2180 \tkzDrawPoints(a,...,d,c',d')
2181 \tkzLabelPoints(a,...,d,c',d')
2182 \end{tikzpicture}
2183 \end{center}
2184 \end{tkzexample}
2185
2186 \subsubsection{Method \tkzMeth{line}{projection\_ll(L, obj)}}
2187 \label{ssub:method_line_projection__ll}
2188
2189 This method performs a projection of a point or a group of points onto a line that is parallel to another reference line.
2190
2191 \medskip
2192
2193 Unlike the standard orthogonal projection (using the line itself), this method projects onto a line that is parallel to the reference line \code{L}, and not necessarily coincident with it.
2194
2195 \medskip
2196
2197 The method accepts the following arguments:
2198 \begin{itemize}
2199 \item \code{L} — a \code{line} object that defines the direction of the projection,
2200 \item \code{obj} — a point or a list of points to be projected.
2201 \end{itemize}
2202
2203
2204 The projection is computed along lines parallel to \code{L}. The result is:
2205 \begin{itemize}
2206 \item a projected point, if the input is a single point,
2207 \item a list of projected points, if the input is a table.
2208 \end{itemize}
2209
2210 \vspace{1em}
2211
2212 \begin{tkzexample}[latex=.5\textwidth]
2213 \directlua{
2214 init_elements()
2215 z.a = point(0, 0)
2216 z.b = point(4, 1)
2217 z.c = point(-1, 3)
2218 z.d = point(-2, -1)
2219 z.m = point(1, 2)
2220 z.n = point(3, 2)
2221 L.ab = line(z.a, z.b)
2222 L.cd = line(z.c, z.d)
2223 z.e,
2224 z.f = L.ab:projection_ll(L.cd, z.m, z.n)}
2225 \begin{center}
2226 \begin{tikzpicture}
2227 \tkzGetNodes
2228 \tkzDrawLines(a,b c,d e,m f,n)
2229 \tkzDrawPoints(a,...,f,m,n)
2230 \tkzLabelPoints(a,...,f,m,n)
2231 \end{tikzpicture}
2232 \end{center}
2233
2234 \end{tkzexample}
2235
2236 \subsubsection{Method \tkzMeth{line}{affinity(L, k, obj)}}
2237 \label{ssub:method_line_affinity}
2238
2239 The introduction of parallel projection onto a given direction allows the definition of a new geometric transformation: \emph{affinity}.
2240
2241 \medskip
2242
2243 This method applies an affine transformation to a point or a group of points, using the line \code{L} to define the direction of the transformation. The points are projected onto the line associated with the current object along lines parallel to \code{L}.
2244
2245 \medskip
2246
2247 Accepted arguments:
2248 \begin{itemize}
2249 \item \code{L} — a \code{line} object defining the direction of the affinity,
2250 \item \code{obj} — a point or a list of points to transform.
2251 \end{itemize}
2252
2253
2254 This transformation preserves parallelism and the ratio of distances along lines parallel to the axis of affinity.
2255
2256 \vspace{1em}
2257
2258 \begin{tkzexample}[latex=.5\textwidth]
2259 \directlua{
2260 init_elements()
2261 z.a = point(0, 0)
2262 z.b = point(4, 1)
2263 z.c = point(-1, 3)
2264 z.d = point(-2, -1)
2265 z.m = point(1,2)
2266 z.n = point(3,2)
2267 L.ab = line(z.a, z.b)
2268 L.cd = line(z.c, z.d)
2269 z.e,
2270 z.f = L.ab:projection_ll(L.cd, z.m, z.n)
2271 z.g,
2272 z.h = L.ab: affinity(L.cd,2, z.m, z.n)
2273 }
2274 \begin{center}
2275 \begin{tikzpicture}
2276 \tkzGetNodes
2277 \tkzDrawLines(a,b c,d e,m f,n)
2278 \tkzDrawPoints(a,...,h,m,n)
2279 \tkzLabelPoints(a,...,h,m,n)
2280 \end{tikzpicture}
2281 \end{center}
2282
2283 \end{tkzexample}
2284
2285 \subsubsection{Method \tkzMeth{line}{translation(obj)}}
2286 \label{ssub:example_translation}
2287
2288 This method performs a translation based on the vector defined by the segment from \code{pa} to \code{pb}, the two endpoints of the line.
2289
2290 \medskip
2291
2292 The argument \code{obj} can be:
2293 \begin{itemize}
2294 \item a point,
2295 \item a line,
2296 \item a triangle,
2297 \item a circle.
2298 \end{itemize}
2299
2300
2301 The method applies the same translation vector to all components of the object. Other object types may be supported in future versions.
2302
2303 \vspace{1em}
2304
2305 \begin{tkzexample}[latex=.5\textwidth]
2306 \directlua{
2307 init_elements()
2308 z.A = point(0, 0)
2309 z.B = point(1, 2)
2310 z.C = point(-3, 2)
2311 z.D = point(0, 2)
2312 L.AB = line(z.A, z.B)
2313 z.E, z.F = L.AB:translation(z.C, z.D)}
2314 \begin{center}
2315 \begin{tikzpicture}
2316 \tkzGetNodes
2317 \tkzDrawPoints(A,...,F)
2318 \tkzLabelPoints(A,...,F)
2319 \tkzDrawSegments[->,red,> =latex](C,E D,F A,B)
2320 \end{tikzpicture}
2321 \end{center}
2322 \end{tkzexample}
2323
2324 \subsubsection{Method \tkzMeth{line}{reflection(obj)}}
2325 \label{ssub:reflection_of_object}
2326
2327 This method performs an axial (orthogonal) reflection with respect to the line. It corresponds to a symmetry with respect to the axis defined by the segment from \code{pa} to \code{pb}.
2328
2329 \medskip
2330
2331 The argument \code{obj} can be:
2332 \begin{itemize}
2333 \item a point,
2334 \item a line,
2335 \item a triangle,
2336 \item a circle.
2337 \end{itemize}
2338
2339
2340 The method returns the reflected object across the line. Support for additional geometric objects may be added in future versions.
2341
2342 \vspace{1em}
2343
2344 \begin{tkzexample}[latex=.5\textwidth]
2345 \directlua{
2346 init_elements()
2347 z.A = point(0, 0)
2348 z.B = point(4, 1)
2349 z.E = point(0, 2)
2350 z.F = point(3, 3)
2351 z.G = point(4, 2)
2352 L.AB = line(z.A, z.B)
2353 T.EFG = triangle(z.E, z.F, z.G)
2354 T.new = L.AB:reflection(T.EFG)
2355 z.Ep, z.Fp, z.Gp = T.new:get()}
2356
2357 \begin{center}
2358 \begin{tikzpicture}
2359 \tkzGetNodes
2360 \tkzDrawLine(A,B)
2361 \tkzDrawPolygon(E,F,G)
2362 \tkzDrawPolygon[new](E',F',G')
2363 \tkzDrawSegment[red,dashed](E,E')
2364 \end{tikzpicture}
2365 \end{center}
2366 \end{tkzexample}
2367
2368 \subsubsection{Method \tkzMeth{line}{path(n)}: Creating a path}
2369 \label{ssub:line_path}
2370
2371 A line object can be sampled into a sequence of two points using the method \tkzMeth{line}{path(n)}. $n$ indicates the number of segments between the two ends of the segment. This is typically used to create TikZ-compatible paths or intermediate constructions. This \tkzname{path}
2372 exists mainly for compatibility and association with other \tkzname{paths}.
2373 \medskip
2374
2375 \texttt{Note: }
2376
2377 By default, only the two endpoints are used to define the path, c'est à dire $n = 1$. This is suitable for filling or clipping regions. For smooth curves, a larger number of subdivisions is recommended.
2378
2379 \medskip
2380
2381 \begin{mybox}
2382 \begin{verbatim}
2383 L.AB = line(z.A, z.B)
2384 PA.line = L.AB:path()
2385 \end{verbatim}
2386 \end{mybox}
2387
2388 You can then draw the path using:
2389
2390 \begin{mybox}
2391 \begin{verbatim}
2392 \tkzDrawCoordinates(PA.line)
2393 \end{verbatim}
2394 \end{mybox}
2395
2396 or draw the points with
2397
2398 \begin{mybox}
2399 \begin{verbatim}
2400 \tkzDrawPointsFromPath[red,size=2](PA.line)
2401 \end{verbatim}
2402 \end{mybox}
2403
2404 \texttt{Examples}
2405 Three points and four intervals !
2406
2407 \begin{tkzexample}[latex = .5\textwidth]
2408 \directlua{
2409 z.A = point(0, 0)
2410 z.B = point(6, 4)
2411 L.AB = line(z.A, z.B)
2412 PA.AB = L.AB:path(3)
2413 }
2414 \begin{tikzpicture}
2415 \tkzDrawCoordinates[blue](PA.AB)
2416 \tkzDrawPointsFromPath[red,size=2](PA.AB)
2417 \end{tikzpicture}
2418 \end{tkzexample}
2419
2420 Given three points, let's look at how, using the \tkzname{path} method, we can draw the triangle defined by these three points. In this case, only the two ends of each side are required:
2421
2422 \begin{tkzexample}[latex = .5\textwidth]
2423 \directlua{
2424 z.O = point(0, 0)
2425 z.P = point(6, 0)
2426 z.Q = point(2, 4)
2427 T.OPQ = triangle(z.O, z.P, z.Q)
2428 PA.OP = T.OPQ.ab:path(2)
2429 PA.PQ = T.OPQ.bc:path(2)
2430 PA.QO = T.OPQ.ca:path(2)
2431 PA.zone = PA.OP + PA.PQ + PA.QO}
2432 \begin{tikzpicture}
2433 \tkzGetNodes
2434 \tkzDrawCoordinates[cyan](PA.zone)
2435 \tkzDrawPoints(O,P,Q)
2436 \end{tikzpicture}
2437 \end{tkzexample}
2438
2439 With |\tkzDrawCoordinates[cyan,fill = orange!10](PA.zone)|, you can fill inside the path.
2440
2441 In the following example, if you want to trace the contour of an angular sector, you'll need to use more points to define the various paths. Otherwise, distortions will appear at path junctions.
2442
2443 \begin{tkzexample}[latex = .5\textwidth]
2444 \directlua{
2445 z.A = point(0, 0)
2446 z.B = point(1, 2)
2447 C.AB = circle(z.A, z.B)
2448 z.E = C.AB:point(1 / 6)
2449 z.C = C.AB:point(0.25)
2450 z.D = C.AB:point(0.5)
2451 L.AB = line(z.A, z.B)
2452 L.CA = line(z.C, z.A)
2453 PA.arcBC = C.AB:path(z.B, z.C, 20)
2454 PA.AB = L.AB:path(5)
2455 PA.CA = L.CA:path(5)
2456 PA.sector = PA.AB + PA.arcBC + PA.CA
2457 }
2458 \begin{tikzpicture}
2459 \tkzGetNodes
2460 \tkzDrawCoordinates[smooth,red,
2461 fill = purple!20](PA.sector)
2462 \tkzDrawPoints(A,B,C)
2463 \tkzDrawPoints(A,B,C)
2464 \end{tikzpicture}
2465 \end{tkzexample}
2466 \endinput