Debian Codegraph @

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

raw
1 \newpage
2
3 \section{Class \tkzClass{conic}}
4 The variable \tkzVar{conic}{CO} holds a table used to store conics. It is optional, and you are free to choose the variable name. However, using \tkzVar{conic}{CO} is a recommended convention for clarity and consistency. If you use a custom variable (e.g., \code{Conics}), you must initialize it manually. The \code{init\_elements()} function reinitializes the \tkzVar{conic}{CO} table if used.
5
6
7 \subsection{Preamble}
8 To illustrate some of the methods for working with conics, consider the construction of a parabola defined as the locus of all centers of circles tangent to a fixed circle and a line.
9
10 In the example below, the table \code{points} contains the coordinates of these centers. Since \TIKZ{} only requires a list of coordinate pairs enclosed in parentheses, the table is converted accordingly.
11
12 The table that defines the circles is slightly more elaborate. It stores, for each circle, both its center and its point of tangency with the given curve or line. Each entry is a sequence of four coordinates. These sequences are then concatenated into a string using a comma (",") as a separator.
13
14 These coordinates are finally read by \tkzMacro{TikZ}{foreach}, using the |expand list| option.
15
16 \vspace{1em}
17 \directlua{
18 z.O = point(0, 0)
19 z.K = point(0, 1)
20 z.P = point(0, 6)
21 z.M = point(0, 2)
22 z.I = point(1, 0)
23 C.PM = circle (z.P,z.M)
24 PA.center = path()
25 PA.through = path()
26 for t = -0.24, 0.24, 0.004 do
27 if (t > - 0.002 and t < 0.002) then else
28 local a = C.PM:point(t)
29 L.OI = line (z.O, z.I)
30 L.PA = line (z.P, a)
31 local c = intersection(L.OI, L.PA)
32 L.tgt = C.PM: tangent_at (a)
33 local x = intersection(L.tgt, L.OI)
34 local o = tkz.bisector(x, a, c).pb
35 PA.center:add_point(o)
36 PA.through:add_point(a)
37 end
38 end}
39 \begin{center}
40 \begin{tikzpicture}[scale =.5]
41 \tkzGetNodes
42 \tkzDrawCircles[thick, orange](P,M K,M)
43 \tkzDrawCirclesFromPaths[draw,orange,thick](PA.center,PA.through)
44 \tkzDrawCoordinates[smooth,red,ultra thick](PA.center)
45 \end{tikzpicture}
46 \end{center}
47
48
49 Here's the code. Two paths(tables) are created, one containing the points of the parabola, the other the points that define the tangent circles.
50 The parabola is obtained using \TIKZ{}'s ability to draw a curve from a list of coordinates.
51
52 \begin{verbatim}
53 \directlua{
54 z.O = point(0, 0)
55 z.K = point(0, 1)
56 z.P = point(0, 6)
57 z.M = point(0, 2)
58 z.I = point(1, 0)
59 C.PM = circle (z.P,z.M)
60 PA.center = path()
61 PA.through = path()
62 for t = -0.24, 0.24, 0.004 do
63 if (t > - 0.002 and t < 0.002) then else
64 local a = C.PM:point(t)
65 L.OI = line (z.O, z.I)
66 L.PA = line (z.P, a)
67 local c = intersection (L.OI, L.PA)
68 L.tgt = C.PM:tangent_at (a)
69 local x = intersection(L.tgt, L.OI)
70 local o = tkz.bisector(x, a, c).pb
71 PA.center:add_point(o)
72 PA.through:add_point(a)
73 end
74 end}
75 \end{verbatim}
76
77 \begin{verbatim}
78 \begin{tikzpicture}[scale =.5]
79 \tkzGetNodes
80 \tkzDrawCircles[thick, orange](P,M K,M)
81 \tkzDrawCirclesFromPaths[draw,orange,thick](PA.center,PA.through)
82 \tkzDrawCoordinates[smooth,red,ultra thick](PA.center)
83 \end{tikzpicture}
84 \end{verbatim}
85 This class replaces the one dedicated to ellipses. From now on, you can work with parabolas, hyperbolas and ellipses. The circle is not part of this class.
86 As you'll see from the examples, ellipses used to be built by \TIKZ{}, now conics are obtained by point-by-point construction. A cloud of points is sent to \TIKZ{}, which simply connects them.
87
88 \begin{mybox}
89 \begin{verbatim}
90 plot[<local options>]coordinates{<coordinate 1><coordinate 2>…<coordinate n>}
91 \end{verbatim}
92 \end{mybox}
93
94 is used by the macro \tkzMacro{tkz-elements}{tkzDrawCoordinates}. One advantage of this method is that you can easily draw only part of a conic.
95
96
97 \subsection{Creating a conic}
98 \label{sub:creating_a_conic}
99
100 The \code{conic} class unifies the construction of all classical conic sections: ellipses, parabolas, and hyperbolas. It supersedes the previously available \code{ellipse} class, which is now deprecated.
101
102 \vspace{1em}
103 The most natural and flexible construction method is based on the classical definition using:
104 \begin{itemize}
105 \item a focus point,
106 \item a directrix (line),
107 \item and an eccentricity value \(e > 0\).
108 \end{itemize}
109
110 \begin{mybox}
111 \begin{verbatim}
112 CO.name = conic(z.F, L.dir, e)
113 \end{verbatim}
114 \end{mybox}
115
116 Depending on the value of the eccentricity:
117 \begin{itemize}
118 \item if \(e = 1\), the result is a parabola;
119 \item if \(e < 1\), an ellipse is constructed;
120 \item if \(e > 1\), the result is a hyperbola.
121 \end{itemize}
122
123 \vspace{1em}
124 \texttt{Short form: }
125
126 The class also supports a short form:
127 \begin{mybox}
128 \begin{verbatim}
129 CO.name = conic(z.F, L.dir, e) -- equivalent to conic:new(...)
130 \end{verbatim}
131 \end{mybox}
132
133 \texttt{Other constructions: }
134
135 The constructor \tkzname{conic:new(...)} remains the only creation mechanism.
136 Additional helper functions are provided to compute valid argument lists
137 from various geometric data. These functions do not construct a conic by
138 themselves; instead, they transform the given data into parameters suitable
139 for the constructor.
140
141 Additional creation methods include:
142 \begin{itemize}
143 \item Bifocal construction using two foci and a constant sum or difference;
144 \item Construction from a center, vertex, and covertex;
145 \item Construction from a general quadratic equation (conic coefficients);
146 \item Construction from five points of an ellipse.
147 \end{itemize}
148
149
150 \verb|CO.EL = conic:new(EL_five_points(A,B,C,D,E))|
151 These alternative methods are described in the following sections.
152
153
154
155 \subsection{Attributes of a conic}
156
157 Parabolas, hyperbolas, and ellipses share many attributes, though some are specific to ellipses and hyperbolas. Originally, ellipses were defined using three points: the center, a vertex, and a co-vertex. From now on, conics are preferably defined by a focus, a directrix, and an eccentricity. The old method remains available, and some tools allow conversion between both definitions.
158
159 \vspace{1em}
160
161 The key attributes for this new definition are:
162 \begin{itemize}
163 \item \tkzAttr{conic}{Fa}: the focus,
164 \item \tkzAttr{conic}{directrix}: the directrix line,
165 \item \tkzAttr{conic}{e}: the eccentricity.
166 \end{itemize}
167
168 \vspace{1em}
169
170 A conic is the locus of all points $P$ such that the ratio of the distance to the focus $F$ over the distance to the directrix $L$ is constant and equal to $e$:
171
172 \[
173 \frac{PF}{PL} = e
174 \]
175
176 Depending on the value of $e$:
177 \begin{itemize}
178 \item If $0 < e < 1$, the conic is an \emph{ellipse}.
179 \item If $e = 1$, it is a \emph{parabola}.
180 \item If $e > 1$, it is a \emph{hyperbola}.
181 \end{itemize}
182
183 \bgroup
184 \catcode`_=12
185 \small
186 \captionof{table}{Conic attributes.}\label{conic:attributes}
187 \begin{tabular}{lll}
188 \toprule
189 \texttt{Attributes} & \textbf{Definition} & \texttt{Reference} \\
190 \midrule
191 \tkzAttr{conic}{Fa} & main foyer of the conic &\\
192 \tkzAttr{conic}{directrix} & directrix of the conic &\\
193 \tkzAttr{conic}{major\_axis} & Axis through focal points &\\
194 \tkzAttr{conic}{minor\_axis} & Axis through focal points &\\
195 \tkzAttr{conic}{e} & eccentricity of the conic &\\
196 \tkzAttr{conic}{type} & The type is 'conic' &\\
197 \tkzAttr{conic}{subtype} & 'parabola', 'hyperbola' or 'ellipse' &\\
198 \tkzAttr{conic}{a} & Only for hyperbola and ellipse &\\
199 \tkzAttr{conic}{b} & Only for hyperbola and ellipse &\\
200 \tkzAttr{conic}{c} & Only for hyperbola and ellipse &\\
201 \tkzAttr{conic}{p} & semi latus rectum &\\
202 \tkzAttr{conic}{slope} & Slope of the line passes through the foci &\\
203 \tkzAttr{conic}{K} & Projection of the focus onto the directrix &\\
204 \tkzAttr{conic}{Fb} & Second focus for hyperbola and ellipse &\\
205 \tkzAttr{conic}{vertex} & main vertex &\\
206 \tkzAttr{conic}{covertex} & \\
207 \tkzAttr{conic}{Rx} & Radius from center to vertex &\\
208 \tkzAttr{conic}{Ry} & Radius from center to covertex &\\
209 \bottomrule %
210 \end{tabular}
211 \egroup
212
213
214
215
216
217 \subsubsection{About attributes of conic}
218
219 The figure below and the associated table show common attributes and differences according to exentricity values.
220
221
222 \begin{verbatim}
223 \directlua{
224 init_elements()
225 z.A = point(0, 0)
226 z.B = point(4, -2)
227 L.dir = line(z.A, z.B)
228 z.F = point(2, 2)
229 CO.EL = conic(z.F, L.dir, 0.8)
230 CO.PA = conic(z.F, L.dir, 1)
231 CO.HY = conic(z.F, L.dir, 1.2)
232 PA.EL = CO.EL:points(0, 1, 40)
233 PA.PA = CO.PA:points(-5, 5, 40)
234 PA.HY = CO.HY:points(-5, 5, 40)
235 z.K = CO.EL.K
236 z.u, z.v = CO.EL.major_axis:get()
237 z.x = L.dir:report(-4, z.K)
238 z.y = L.dir:report(4, z.K)
239 z.r = (z.F - z.K):orthogonal(-4):at(z.F)
240 z.s = (z.F - z.K):orthogonal(4):at(z.F)
241 L.rs = line(z.r, z.s)
242 z.I_1 = intersection(L.rs, CO.EL)
243 z.I_2 = intersection(L.rs, CO.PA)
244 z.I_3, _ = intersection(L.rs, CO.HY)
245 z.H_1 = CO.EL.directrix:projection(z.I_1)
246 z.H_2 = CO.PA.directrix:projection(z.I_2)
247 z.H_3 = CO.HY.directrix:projection(z.I_3)
248 z.S_2 = CO.PA.vertex
249 z.F_1 = CO.EL.Fb
250 z.C_1 = CO.EL.center
251 z.C_3 = CO.HY.center}
252
253 \begin{tikzpicture}[scale=.8]
254 \tkzGetNodes
255 \tkzDrawLines(x,y u,v r,s)
256 \tkzDrawPoints(F,K,I_1,I_2,I_3,S_2)
257 \tkzDrawPoints(H_1,H_2,H_3,F_1,C_1,C_3)
258 \tkzLabelPoints(F,K,H_1,H_2,H_3,F_1,C_1,C_3)
259 \tkzDrawSegments[dashed](I_1,H_1 I_2,H_2)
260 \tkzDrawSegments[dashed](I_3,H_3)
261 \tkzLabelPoints[above](I_1,I_2,I_3,S_2)
262 \tkzDrawCoordinates[smooth](PA.EL)
263 \tkzDrawCoordinates[smooth](PA.PA)
264 \tkzDrawCoordinates[smooth](PA.HY)
265 \tkzLabelSegment[pos=.4](K,F){$h = KF$}
266 \tkzLabelSegment[sloped,pos=-.2](x,y){%
267 \texttt{directrix}}
268 \end{tikzpicture}
269 \end{verbatim}
270
271 \directlua{
272 init_elements()
273 z.A = point(0, 0)
274 z.B = point(4, -2)
275 L.dir = line(z.A, z.B)
276 z.F = point(2, 2)
277 CO.EL = conic(z.F, L.dir, 0.8)
278 CO.PA = conic(z.F, L.dir, 1)
279 CO.HY = conic(z.F, L.dir, 1.2)
280 PA_EL = CO.EL:points(0, 1, 40)
281 PA_PA = CO.PA:points(-5, 5, 40)
282 PA_HY = CO.HY:points(-5, 5, 40)
283 z.K = CO.EL.K
284 z.u, z.v = CO.EL.major_axis:get()
285 z.x = L.dir:report(-4, z.K)
286 z.y = L.dir:report(4, z.K)
287 z.r = (z.F - z.K):orthogonal(-4):at(z.F)
288 z.s = (z.F - z.K):orthogonal(4):at(z.F)
289 L.rs = line(z.r, z.s)
290 z.I_1 = intersection(L.rs, CO.EL)
291 z.I_2 = intersection(L.rs, CO.PA)
292 z.I_3, _ = intersection(L.rs, CO.HY)
293 z.H_1 = CO.EL.directrix:projection(z.I_1)
294 z.H_2 = CO.PA.directrix:projection(z.I_2)
295 z.H_3 = CO.HY.directrix:projection(z.I_3)
296 z.S_2 = CO.PA.vertex
297 z.F_1 = CO.EL.Fb
298 z.C_1 = CO.EL.center
299 z.C_3 = CO.HY.center}
300
301 \begin{center}
302 \begin{tikzpicture}[scale=.5]
303 \tkzGetNodes
304 \tkzDrawLines(x,y u,v r,s)
305 \tkzDrawPoints(F,K,I_1,I_2,I_3,S_2,H_1,H_2,H_3,F_1,C_1,C_3)
306 \tkzLabelPoints(F,K,H_1,H_2,H_3,F_1,C_1,C_3)
307 \tkzDrawSegments[dashed](I_1,H_1 I_2,H_2 I_3,H_3)
308 \tkzLabelPoints[above](I_1,I_2,I_3,S_2)
309 \tkzDrawCoordinates[smooth](PA_EL)
310 \tkzDrawCoordinates[smooth](PA_PA)
311 \tkzDrawCoordinates[smooth](PA_HY)
312 \tkzLabelSegment[pos=.4](K,F){$h = KF$}
313 \tkzLabelSegment[sloped,pos=-.2](x,y){\texttt{directrix}}
314 \tkzText[draw,
315 inner sep=10pt,
316 line width = 1pt,
317 text width=6cm](2,17.5){The focus $F$, the line \code{directrix} and the value of $h =KF$ are attributes common to all three conics. These conics differ in their eccentricity $e$, here $0.8$ for the ellipse, $1$ for the parabola and $1.2$ for the hyperbola. The \code{semi latus rectum} $p$ is equal to $e*h$ and differs depending on the conic. It is represented by $FI_1$, $FI_2$ and $FI_3$. By definition, $\displaystyle e = \frac{p}{h}$}
318 \end{tikzpicture}
319 \end{center}
320
321
322 \subsubsection{Attributes of a parabola}
323
324 Let
325
326 \begin{center}
327 \code{CO.PA = conic(z.F, L.AB, 1)}
328 \end{center}
329
330 The focus is $F$, accessed via \code{CO.PA.Fa}. Since the eccentricity is $1$, the conic is a parabola. Unlike ellipses and hyperbolas, a parabola has only one focus and no center. Its definition line, the directrix, is stored in \code{CO.PA.directrix}, and its type is identified by the attribute \code{CO.PA.subtype = 'parabola'}.
331
332 \vspace{1em}
333
334 The projection of $F$ onto the directrix is the point $K$, obtained with \code{CO.PA.K}. The semi-latus rectum $p$ is given by $e \cdot h$, and here $p = h$. The vertex of the parabola, the midpoint of the segment $[KF]$, is stored as \code{CO.PA.vertex}. Unlike ellipses, the parabola does not have a \code{covertex}.
335
336 \vspace{1em}
337
338 In a coordinate system centered at the vertex $S$ and aligned with the axis of the parabola, the equation becomes $y = \dfrac{x^2}{2p}$. The usual parameters $a$, $b$, and $c$ for conics are not defined here, as they relate to centered conics only.
339
340 \vspace{1em}
341
342 Two attributes are common to all conics:
343 \begin{itemize}
344 \item \code{CO.PA.major\_axis}, the main axis from $K$ to $F$;
345 \item \code{CO.PA.slope}, the angle between this axis and the horizontal.
346 \end{itemize}
347
348 \vspace{1em}
349 \directlua{
350 init_elements()
351 z.A = point(0, 0)
352 z.B = point(4, -2)
353 L.dir = line(z.A, z.B)
354 z.F = point(2, 2)
355 CO.PA = conic(z.F, L.dir, 1)
356 PA.curve2 = CO.PA:points(-5, 5, 20)
357 z.K = CO.PA.K
358 z.u, z.v = CO.PA.major_axis:get()
359 z.x = L.dir:report(-4, z.K)
360 z.y = L.dir:report(4, z.K)
361 z.r = (z.F - z.K):orthogonal(-4):at(z.F)
362 z.s = (z.F - z.K):orthogonal(4):at(z.F)
363 L.rs = line(z.r, z.s)
364 _, z.I_2 = intersection(L.rs, CO.PA)
365 z.H_2 = CO.PA.directrix:projection(z.I_2)
366 z.S_2 = CO.PA.vertex}
367
368 \begin{tikzpicture}
369 \tkzGetNodes
370 \tkzDrawLines(x,y u,v r,s)
371 \tkzDrawPoints(F,K,I_2,S_2,H_2)
372 \tkzLabelPoints(F,K,H_2)
373 \tkzDrawSegments[dashed](I_2,H_2)
374 \tkzLabelPoints[above](I_2,S_2)
375 \tkzDrawCoordinates[smooth](PA.curve2)
376 \tkzLabelSegment[pos=.8](K,F){$h = p = KF$}
377 \tkzLabelSegment[above,pos=.5](F,I_2){$ p = h = FI_2$}
378 \tkzLabelSegment[sloped,pos=.8](x,y){\texttt{directrix}}
379 \tkzLabelSegment[left](K,S_2){$h/2$}
380 \end{tikzpicture}
381
382 \subsubsection{Attributes of a hyperbola}
383
384 Let
385
386 \begin{center}
387 \code{CO.HY = conic(z.F, L.AB, 1.2)}
388 \end{center}
389
390
391 In this case, the eccentricity is greater than $1$, so the conic is a hyperbola. As with all conics, the focus is given by \code{CO.HY.Fa}, the directrix by \code{CO.HY.directrix}, and the subtype is identified by \code{CO.HY.subtype = 'hyperbola'}.
392
393 \vspace{1em}
394
395 Two specific attributes of hyperbolas are:
396 \begin{itemize}
397 \item the second focus, \code{CO.HY.Fb},
398 \item the center of the hyperbola, \code{CO.HY.center}.
399 \end{itemize}
400
401 \vspace{1em}
402
403 Several key segments characterize the hyperbola:
404 \begin{itemize}
405 \item $a = \overline{CS}$ is the distance from the center to a vertex, accessed with \code{CO.HY.a},
406 \item $c = \overline{CF}$ is the distance from the center to a focus, accessed with \code{CO.HY.c}.
407 \end{itemize}
408
409 \vspace{1em}
410
411 The main axis (\code{CO.HY.major\_axis}) and its slope (\code{CO.HY.slope}) are also available, as with all conics.
412
413 \directlua{
414 init_elements()
415 z.A = point(0, 0)
416 z.B = point(4, -2)
417 L.dir = line(z.A, z.B)
418 z.F = point(2, 1.8)
419 CO.HY = conic(z.F, L.dir, 2)
420 PA.curve = CO.HY:points(-6, 6, 20)
421 PA.curves = CO.HY:points(-5, 5, 20, "swap")
422 z.K = CO.HY.K
423 z.u, z.v = CO.HY.major_axis:get()
424 z.x = L.dir:report(-4, z.K)
425 z.y = L.dir:report(4, z.K)
426 z.r = (z.F - z.K):orthogonal(-5):at(z.F)
427 z.s = (z.F - z.K):orthogonal(5):at(z.F)
428 L.rs = line(z.r, z.s)
429 _, z.I = intersection(L.rs, CO.HY)
430 z.H = CO.HY.directrix:projection(z.I)
431 z.S = CO.HY.vertex
432 z.C = CO.HY.center
433 z.G = CO.HY.Fb
434 z.E = CO.HY.covertex
435 z.D = (z.S - z.C):orthogonal(CO.HY.b):at(z.S)}
436
437 \begin{center}
438 \begin{tikzpicture}
439 \tkzGetNodes
440 \tkzDrawLines(x,y r,s G,F)
441 \tkzDrawLine[red,add= 0 and 1](C,D)
442 \tkzDrawLines[add = -.2 and -.2](u,v)
443 \tkzDrawPoints(E,F,K,I,S,H,C,G,D)
444 \tkzLabelPoints[right](E,F,K,H,C,D,G)
445 \tkzDrawSegments[dashed](I,H)
446 \tkzDrawPolySeg[dashed](C,E,D,S)
447 \tkzLabelPoint[right](F){$F$ focus}
448 \tkzLabelPoints[above](I,S)
449 \tkzDrawCoordinates[smooth](PA.curve)
450 \tkzDrawCoordinates[smooth](PA.curves)
451 \tkzLabelSegment[pos=.6,right=8 pt](K,F){$h = KF$}
452 \tkzLabelSegment[pos=.6,sloped](I,F){$p = IF = e*h$}
453 \tkzLabelSegment[sloped,pos=.8](x,y){\texttt{directrix}}
454 \tkzLabelSegment[sloped,pos=.4](C,D){\color{red}\texttt{asymptote}}
455 \tkzLabelSegment[pos=1.6](C,D){\color{red}\texttt{slope = $\displaystyle\frac{b}{a}$}}
456 \tkzText[
457 inner sep=10pt,
458 line width = 1pt,
459 text width=4cm](-3,-4){
460 $CS = a$\\
461 $CF = c$\\
462 $CE = b$\\
463 slope of asymptote = $\displaystyle\frac{b}{a}$\\
464 $IF = p = e*h$\\
465 $KF = h$
466 }
467 \end{tikzpicture}
468 \end{center}
469
470 \subsubsection{Attributes of an ellipse}
471
472 An ellipse shares many attributes with the hyperbola. It is created using the same method, for example:
473
474
475 \begin{center}
476 \code{CO.EL = conic(z.F, L.AB, 0.8)}
477 \end{center}
478
479
480 \vspace{1em}
481
482 As usual, the focus is given by \code{CO.EL.Fa}, the directrix by \code{CO.EL.directrix}, and the subtype is identified by \code{CO.EL.subtype = 'ellipse'}. Since the eccentricity is less than $1$, the conic is an ellipse.
483
484 \vspace{1em}
485
486 Specific attributes include:
487 \begin{itemize}
488 \item the second focus: \code{CO.EL.Fb},
489 \item the center of the ellipse: \code{CO.EL.center}.
490 \end{itemize}
491
492 \vspace{1em}
493
494 Distances used to characterize the ellipse:
495 \begin{itemize}
496 \item $a = \overline{CS}$: distance from the center to a vertex, accessed via \code{CO.EL.a},
497 \item $b = \overline{CM}$: semi-minor axis (perpendicular to the major axis), via \code{CO.EL.b},
498 \item $c = \overline{CF}$: distance from the center to a focus, via \code{CO.EL.c}.
499 \end{itemize}
500
501 \vspace{1em}
502
503 The relationship between these distances for an ellipse is:
504 \[
505 c = \sqrt{a^2 - b^2}
506 \]
507 as opposed to the hyperbola, where $c = \sqrt{a^2 + b^2}$.
508
509 \vspace{1em}
510
511 As for all conics, the major axis is available via \code{CO.EL.major\_axis}, and its orientation via \code{CO.EL.slope}.
512
513 \directlua{
514 init_elements()
515 z.A = point(0, 0)
516 z.B = point(4, -2)
517 L.dir = line(z.A, z.B)
518 z.F = point(2, 2)
519 CO.HY = conic(z.F, L.dir, 0.75)
520 PA.curve = CO.HY:points(0, 6.3, 20)
521 z.K = CO.HY.K
522 z.u, z.v = CO.HY.major_axis:get()
523 z.x = L.dir:report(-4, z.K)
524 z.y = L.dir:report(4, z.K)
525 z.r = (z.F - z.K):orthogonal(-5):at(z.F)
526 z.s = (z.F - z.K):orthogonal(5):at(z.F)
527 L.rs = line(z.r, z.s)
528 z.I, z.J = intersection(L.rs, CO.HY)
529 z.H = CO.HY.directrix:projection(z.I)
530 z.V = CO.HY.vertex
531 z.C = CO.HY.center
532 z.G = CO.HY.Fb
533 z.E = CO.HY.covertex}
534
535
536 \begin{center}
537 \begin{tikzpicture}
538 \tkzGetNodes
539 \tkzDrawCoordinates[smooth](PA.curve)
540 \tkzDrawLines(x,y I,J G,K)
541 \tkzDrawLines[add = -.2 and -.2](u,v)
542 \tkzDrawPoints(E,F,K,I,V,H,C,G)
543 \tkzLabelPoints[right](E,F,K,H,C,G)
544 \tkzDrawSegments[dashed](I,H)
545 \tkzLabelPoint[right](F){$F$ focus}
546 \tkzLabelPoints[above right](I,V)
547 \tkzLabelSegment[pos=.6,right=8 pt](K,V){$h = KF$}
548 \tkzLabelSegment[pos=.5,above right](I,F){$p = IF = e*h$}
549 \tkzLabelSegment[sloped,pos=.8](x,y){\texttt{directrix}}
550 \tkzText[
551 inner sep=10pt,
552 line width = 1pt,
553 text width=4cm](-3,-2){
554 $CV = a$\\
555 $CF = c$\\
556 $CE = b$\\
557 $IF = p = e*h$\\
558 $KF = h$
559 }
560 \end{tikzpicture}
561 \end{center}
562
563 \subsection{Point-by-point conic construction}
564
565 Let’s take a closer look at the methods used to construct conics. The general approach is to generate a table of points ---with a nearly constant number--- to define the curve’s path. This table is then passed to \TIKZ{} to produce the plot.
566
567
568 \subsubsection{Parabola construction}
569 \label{ssub:parabola_construction}
570
571 The construction method is based on the following geometric property: if a point $M$ lies on a parabola, then the bisector of the segment joining the focus $F$ and the projection $H$ of $M$ onto the directrix is also the angle bisector of $\widehat{HMF}$ and corresponds to the tangent to the parabola at $M$.
572
573 This principle is used to determine a discrete set of points forming the parabola.
574
575 The result is stored in a table called \code{curve}, which contains the coordinates of the points on the conic. The directrix is assumed to coincide with the x-axis. You must specify:
576 \begin{itemize}
577 \item the starting abscissa,
578 \item the ending abscissa,
579 \item and the number of points to compute.
580 \end{itemize}
581
582 The name \code{curve} is only a suggestion—you may use any name you like for the table.
583
584
585 \vspace{1em}
586
587 \begin{minipage}{.5\textwidth}
588 \begin{verbatim}
589 \directlua{
590 init_elements()
591 z.A = point(0, 1)
592 z.B = point(4, 3)
593 z.F = point(2, 6)
594 L.AB = line(z.A, z.B)
595 CO.PA = conic(z.F, L.AB, 1)
596 z.K = CO.PA.K
597 z.M = CO.PA:point(-2)
598 z.H = CO.PA.directrix:projection(z.M)
599 L.FH = line(z.F, z.H)
600 L.med = L.FH:mediator()
601 L.orth = CO.PA.directrix:ortho_from(z.H)
602 z.T = intersection(L.AB, L.med)
603 PA.curve = CO.PA:points(-5, 5, 50)
604 z.m = tkz.midpoint(z.H, z.F)}
605
606 \begin{tikzpicture}
607 \tkzGetNodes
608 \tkzDrawCoordinates[smooth](PA.curve)
609 \tkzDrawLines[add = .5 and .5](A,B M,T K,F)
610 \tkzDrawSegments(M,H H,F F,M)
611 \tkzDrawPoints(F,K,T,M,H)
612 \tkzLabelPoints(F,K,T,M,H)
613 \tkzMarkAngles[mark=|](H,M,T T,M,F)
614 \tkzMarkSegments[mark=|](H,M M,F)
615 \tkzMarkSegments[mark=|](H,m m,F)
616 \end{tikzpicture}
617 \end{verbatim}
618 \end{minipage}
619 \directlua{
620 init_elements()
621 z.A = point(0, 1)
622 z.B = point(4, 3)
623 z.F = point(2, 6)
624 L.AB = line(z.A, z.B)
625 CO.PA = conic(z.F, L.AB, 1)
626 z.K = CO.PA.K
627 z.M = CO.PA:point(-2)
628 z.H = CO.PA.directrix:projection(z.M)
629 L.FH = line(z.F, z.H)
630 L.med = L.FH:mediator()
631 L.orth = CO.PA.directrix:ortho_from(z.H)
632 z.T = intersection(L.AB, L.med)
633 PA.curve = CO.PA:points(-5, 5, 50)
634 z.m = tkz.midpoint(z.H, z.F)}
635 \begin{minipage}{.5\textwidth}
636 \begin{center}
637 \begin{tikzpicture}[scale=.75]
638 \tkzGetNodes
639 \tkzDrawCoordinates[smooth](PA.curve)
640 \tkzDrawLines[add = .5 and .4](A,B M,T K,F)
641 \tkzDrawSegments(M,H H,F F,M)
642 \tkzDrawPoints(F,K,T,M,H)
643 \tkzLabelPoints(F,K,T,M,H)
644 \tkzMarkAngles[mark=|](H,M,T T,M,F)
645 \tkzMarkSegments[mark=|](H,M M,F)
646 \tkzMarkSegments[mark=|](H,m m,F)
647 \end{tikzpicture}
648 \end{center}
649 \end{minipage}
650
651
652
653 \subsubsection{Hyperbola construction}
654 \label{ssub:hyperbola_construction}
655
656 Constructing a hyperbola is slightly more involved.
657
658 Let $K$ be the projection of the focus $F$ onto the directrix. The distance $FK$ is denoted $h$, and is used to compute the center $C$ of the hyperbola. Let $e$ be the eccentricity. The distance from the focus to the center is given by:
659 \[
660 c = \dfrac{e^2 h}{e^2 - 1}
661 \]
662 From this, the distance between the center and a vertex of the hyperbola is:
663 \[
664 a = \dfrac{e h}{e^2 - 1} \quad \text{or equivalently} \quad a = \dfrac{c}{e}
665 \]
666
667 To construct a point on the hyperbola:
668 \begin{itemize}
669 \item Select a point $T$ on the directrix.
670 \item Construct the line $(FT)$ through the focus and $T$.
671 \item This line intersects the perpendiculars at $K$ and $C$ (to the line $(FK)$) at points $E$ and $D$ respectively.
672 \item The circle centered at $D$ and passing through $E$ intersects the perpendicular to the directrix at $T$ in a point $P$.
673 \end{itemize}
674
675 This point $P$ lies on the hyperbola.
676
677
678 \directlua{
679 init_elements()
680 z.A = point(-2, -1)
681 z.B = point(4, 0)
682 L.AB = line(z.A, z.B)
683 z.F = point(0, 3)
684 CO.HY = conic(z.F, L.AB, 2)
685 PA.curve = CO.HY:points(-5, 5, 50)
686 z.K = CO.HY.K
687 z.S = CO.HY.vertex
688 z.O = CO.HY.center
689 z.X = CO.HY:point(2)
690 z.T = CO.HY.directrix:report(2, CO.HY.K)
691 LT = CO.HY.major_axis:ll_from(z.T)
692 z.u, z.v = LT:get()
693 LC = CO.HY.minor_axis
694 LS = LC:ll_from(CO.HY.vertex)
695 z.D = intersection_ll_(LC.pa, LC.pb, CO.HY.Fa, z.T)
696 z.E = intersection_ll_(LS.pa, LS.pb, CO.HY.Fa, z.T)
697 z.P, z.Q = intersection_lc_(LT.pa, LT.pb, z.D, z.E)
698 z.C = CO.HY.center}
699 \begin{center}
700 \begin{tikzpicture}[scale = 1]
701 \tkzGetNodes
702 \tkzDrawCoordinates[smooth,cyan](PA.curve)
703 \tkzDrawCircle(D,E)
704 \tkzDrawLines(F,C F,D)
705 \tkzDrawLines[add = 1 and 1](T,P)
706 \tkzDrawPoints(C,F,K,S,T,P,D,E)
707 \tkzLabelPoints(C,F,K,S,T,D,E)
708 \tkzLabelPoint[below,sloped](A){directrix}
709 \tkzLabelPoints[above](P)
710 \tkzDrawSegments(A,K T,B)
711 \tkzDrawSegments[dashed](S,E K,T C,D)
712 \end{tikzpicture}
713 \end{center}
714
715 \begin{verbatim}
716 \directlua{
717 init_elements()
718 z.A = point(-2, -1)
719 z.B = point(4, 0)
720 L.AB = line(z.A, z.B)
721 z.F = point(0, 3)
722 CO.HY = conic(z.F, L.AB, 2)
723 PA.curve = CO.HY:points(-5, 5, 50)
724 z.K = CO.HY.K
725 z.S = CO.HY.vertex
726 z.O = CO.HY.center
727 z.X = CO.HY:point(2)
728 z.T = CO.HY.directrix:report(2, CO.HY.K)
729 LT = CO.HY.major_axis:ll_from(z.T)
730 z.u, z.v = LT:get()
731 LC = CO.HY.minor_axis
732 LS = LC:ll_from(HY.vertex)
733 z.D = intersection_ll_(LC.pa, LC.pb, CO.HY.Fa, z.T)
734 z.E = intersection_ll_(LS.pa, LS.pb, CO.HY.Fa, z.T)
735 z.P, z.Q = intersection_lc_(LT.pa, LT.pb, z.D, z.E)
736 z.C = CO.HY.center}
737 \begin{tikzpicture}
738 \tkzGetNodes
739 \tkzDrawCoordinates[smooth,cyan](PA.curve)
740 \tkzDrawCircle(D,E)
741 \tkzDrawLines(F,C F,D)
742 \tkzDrawLines[add = 1 and 1](T,P)
743 \tkzDrawPoints(C,F,K,S,T,P,D,E)
744 \tkzLabelPoints(C,F,K,S,T,D,E)
745 \tkzLabelPoint[below,sloped](A){directrix}
746 \tkzLabelPoints[above](P)
747 \tkzDrawSegments(A,K T,B)
748 \tkzDrawSegments[dashed](S,E K,T C,D)
749 \end{tikzpicture}
750 \end{verbatim}
751
752 \subsubsection{Ellipse construction}
753
754 The ellipse can be constructed point by point using an affinity. This transformation is applied to the principal circle, using the focal axis as the direction of the affinity and a ratio equal to $b/a$, where $a$ and $b$ are the semi-major and semi-minor axes of the ellipse.
755
756 Let $Q$ be a point on the principal circle, and $H$ its projection onto the focal axis. Consider the segment $OA = a$ on the focal axis, and the segment $OB = b$ perpendicular to it. Draw the line $(AB)$ and then a line parallel to it passing through $Q$. This line intersects the focal axis at point $T$.
757
758 By construction, the similarity ratio is:
759 \[
760 \frac{b}{a} = \frac{HT}{HQ}
761 \]
762 Now, if we reflect $Q$ over $T$, we obtain a new point $Q'$ such that $HT = HQ'$. Hence:
763 \[
764 \frac{HQ'}{HQ} = \frac{b}{a}
765 \]
766
767 The point $Q'$ lies on the ellipse. Repeating this construction for various points $Q$ on the principal circle gives the ellipse as the image of the circle under the affinity.
768
769 \begin{minipage}{.5\textwidth}
770 \begin{verbatim}
771 \directlua{
772 init_elements()
773 z.Fb = point(3, 0)
774 z.Fa = point(-3, 2)
775 local c = tkz.length(z.Fa, z.Fb) / 2
776 local a = 4
777 local b = math.sqrt(a ^ 2 - c ^ 2)
778 local e = c / a
779 L.focal = line(z.Fa, z.Fb)
780 z.O = L.focal.mid
781 L.OFb = line(z.O, z.Fb)
782 z.K = L.OFb:report(a ^ 2 / c)
783 z.Ko = ortho_from_(z.K, z.K, z.Fb)
784 L.dir = line(z.K, z.Ko)
785 CO.EL = conic(z.Fb, L.dir, e)
786 PA.curve = CO.EL:points(0, 1, 100)
787 z.V = CO.EL.vertex
788 local C = circle(z.O, CO.EL.vertex)
789 z.A = C:point(0.25)
790 z.B = L.focal:report(-CO.EL.b, z.O)
791 z.Q = C:point(0.2)
792 z.H = L.focal:projection(z.Q)
793 z.Qp = L.focal:affinity(L.focal:
794 ortho_from(z.O), b / a, z.Q)
795 z.T = intersection_ll_(z.Q,
796 ll_from_(z.Q, z.A, z.B), z.Fb, z.Fa)}
797 \begin{tikzpicture}
798 \tkzGetNodes
799 \tkzDrawCoordinates[smooth](PA.curve)
800 \tkzDrawLines(Fa,Fb K,Ko)
801 \tkzDrawLines[add = 2 and 2](K,Ko)
802 \tkzDrawSegments[dashed](H,Q O,A)
803 \tkzDrawCircles(O,Q H,T)
804 \tkzDrawPoints(Fa,Fb,Q,Q',H,V,A,B,O,K)
805 \tkzDrawSegments[red](A,B Q,T)
806 \tkzLabelPoints(Fa,Fb,Q,Q',H,V,A,B,O,K)
807 \tkzLabelSegment(K,Ko){directrix}
808 \end{tikzpicture}
809 \end{verbatim}
810 \end{minipage}
811 \begin{minipage}{.5\textwidth}
812 \directlua{
813 init_elements()
814 z.Fb = point(3, 0)
815 z.Fa = point(-3, 2)
816 local c = tkz.length(z.Fa, z.Fb) / 2
817 local a = 4
818 local b = math.sqrt(a ^ 2 - c ^ 2)
819 local e = c / a
820 L.focal = line(z.Fa, z.Fb)
821 z.O = L.focal.mid
822 L.OFb = line(z.O, z.Fb)
823 z.K = L.OFb:report(a ^ 2 / c)
824 z.Ko = ortho_from_(z.K, z.K, z.Fb)
825 L.dir = line(z.K, z.Ko)
826 CO.EL = conic(z.Fb, L.dir, e)
827 curve = CO.EL:points(0, 1, 100)
828 z.V = CO.EL.vertex
829 local C = circle(z.O, CO.EL.vertex)
830 z.A = C:point(0.25)
831 z.B = L.focal:report(-CO.EL.b, z.O)
832 z.Q = C:point(0.2)
833 z.H = L.focal:projection(z.Q)
834 z.Qp = L.focal:affinity(L.focal:
835 ortho_from(z.O), b / a, z.Q)
836 z.T = intersection_ll_(z.Q,
837 ll_from_(z.Q, z.A, z.B), z.Fb, z.Fa)}
838 \begin{center}
839 \begin{tikzpicture}[scale = .75]
840 \tkzGetNodes
841 \tkzDrawCoordinates[smooth](curve)
842 \tkzDrawLines(Fa,Fb K,Ko)
843 \tkzDrawLines[add = 2 and 2](K,Ko)
844 \tkzDrawSegments[dashed](H,Q O,A)
845 \tkzDrawCircles(O,Q H,T)
846 \tkzDrawPoints(Fa,Fb,Q,Q',H,V,A,B,O,K)
847 \tkzDrawSegments[red](A,B Q,T)
848 \tkzLabelPoints(Fa,Fb,Q,Q',H,V,A,B,O,K)
849 \tkzLabelSegment(K,Ko){directrix}
850 \end{tikzpicture}
851 \end{center}
852 \end{minipage}
853
854 \subsection{Methods of the class conic}
855
856 The methods previously designed for the (now obsolete) \code{ellipse} class have been generalized to the \code{conic} class.
857
858 The most natural creation method is now the one based on a focus, a directrix, and the eccentricity.
859
860 \begin{mybox}
861 \begin{verbatim}
862 CO = conic(z.F,L.dir,e)
863 \end{verbatim}
864 \end{mybox}
865
866 Depending on the latter, it is easy to distinguish between parabolas, hyperbolas, and ellipses. The bifocal definition of hyperbolas and ellipses is also available, as well as the one based on three points: the center, a vertex, and a covertex.
867
868 \bgroup
869 \catcode`_=12
870 \small
871 \captionof{table}{Conic methods.}\label{conic:methods}
872 \begin{tabular}{ll}
873 \toprule
874 \texttt{Methods} & \texttt{Reference} \\
875 \midrule
876 \texttt{Constructor} & \\
877 \midrule
878 \tkzMeth{conic}{new (pt, L , e) } & CO = conic: new ( focus, directrix,eccentricity )\\
879 \midrule
880 \texttt{Methods Returning a Point}&\\
881 \midrule
882 \tkzMeth{conic}{get(i)}& [\ref{ssub:method_conic_get}]\\
883 \tkzMeth{conic}{point(t)} & [\ref{ssub:method_conic_points}]\\
884 \midrule
885 \texttt{Methods Returning a String}&\\
886 \midrule
887 \tkzMeth{conic}{position(pt)} & [\ref{ssub:method_conic_position}] \\
888 \midrule
889 \texttt{Methods Returning a Boolean}&\\
890 \midrule
891 \tkzMeth{conic}{in\_out(pt)} & [\ref{ssub:method_conic_in_out}] \\
892 \midrule
893 \texttt{Methods Returning a Line}&\\
894 \midrule
895 \tkzMeth{conic}{tangent\_at(pt)} & [\ref{ssub:method_conic_tangent_at}] \\
896 \tkzMeth{conic}{tangent\_from(pt)}& [\ref{ssub:method_conic_tangent_from}] \\
897 \tkzMeth{conic}{asymptotes()} & [\ref{ssub:conic_asymptotes}] \\
898 \midrule
899 \tkzMeth{conic}{orthoptic\_curve()}& [\ref{ssub:method_conic_orthoptic}] \\
900 \midrule
901 \texttt{Methods Returning a Path}&\\
902 \midrule
903 \tkzMeth{conic}{path(pt, pt, nb, swap)} & [\ref{ssub:conic_path}] \\
904 \tkzMeth{conic}{points(ta,tb,nb,<'sawp'>)} & See [ \ref{ssub:method_conic_points}] \\
905 \bottomrule
906 \end{tabular}
907 \egroup
908
909 \bgroup
910 \catcode`_=12
911 \small
912 \captionof{table}{Conic functions.}\label{conic:functions}
913 \begin{tabular}{ll}
914 \toprule
915 \texttt{Functions} & \texttt{Reference} \\
916 \midrule
917 \tkzFct{conic}{PA\_dir(pt,pt,pt)} & [\ref{ssub:pa_dir}] \\
918 \tkzFct{conic}{PA\_focus(L,pt,pt)}& [\ref{ssub:_igfct_math_pa__focus}] \\
919 \tkzFct{conic}{HY\_bifocal(pt,pt,pt or r)}& [\ref{ssub:_igfct_math_hy__bifocal}] \\
920 \tkzFct{conic}{EL\_bifocal(pt,pt,pt or r)}& [\ref{ssub:_igfct_math_el__bifocal}] \\
921 \tkzFct{conic}{EL\_points(L,pt,pt)}&[\ref{ssub:_math_el__points}] \\
922 \tkzFct{conic}{search\_ellipse(s1, s2, s3, s4, s5)}&[\ref{ssub:search_ellipse}]\\\tkzFct{conic}{test\_ellipse(pt,t)}&[\ref{ssub:function_test_ellipse}] \\
923 \tkzFct{conic}{search\_center\_ellipse(t)}&[\ref{ssub:function_search_center_ellipse}] \\
924 \tkzFct{conic}{ellipse\_axes\_angle(t)} &[\ref{ssub:function_ellipse_axes_angle}] \\
925 \bottomrule
926 \end{tabular}
927 \egroup
928
929 \subsubsection{Method \tkzMeth{conic}{get()}}
930 \label{ssub:method_conic_get}
931
932 This method retrieves the main characteristic points of a conic.
933 The points returned depend on the subtype of the conic (ellipse, hyperbola, or parabola), but the calling convention is uniform.
934
935 \begin{itemize}
936 \item For a \emph{parabola}, the defining points are the vertex and the focus.
937 \item For an \emph{ellipse} or a \emph{hyperbola}, the defining points are the center and the two foci.
938 \end{itemize}
939
940 \medskip
941
942 \begin{itemize}
943 \item \code{C:get()} returns all defining points of the conic.
944 \item \code{C:get(1)} returns the first defining point.
945 \item \code{C:get(2)} returns the second defining point.
946 \item \code{C:get(3)} returns the third defining point, if it exists.
947 \end{itemize}
948
949 \medskip
950
951 More precisely:
952 \begin{itemize}
953 \item For a parabola, \code{C:get()} returns the vertex and the focus.
954 \item For an ellipse or a hyperbola, \code{C:get()} returns the center and the two foci.
955 \end{itemize}
956
957 This method provides a unified way to access the essential points of a conic, independently of its construction (focus--directrix definition, axis-based construction, etc.). It is particularly useful for composing constructions, exporting points, or defining derived geometric objects.
958
959
960 \subsubsection{Method \tkzMeth{conic}{points}}
961 \label{ssub:method_conic_points}
962
963 This method generates a set of points lying on the conic. These points can then be used with \tkzNamePack{tkz-euclide}, which, via \TIKZ{}'s \code{draw[options] plot coordinates}, will render the curve.
964
965 The method requires three arguments: the minimum value of the parameter $t$, the maximum value, and the number of intermediate points between these two bounds.
966
967 \begin{mybox}
968 \begin{verbatim}
969 CO = conic(z.F, L.dir, e)
970 curve = CO:points(ta, tb, nb)
971 \end{verbatim}
972 \end{mybox}
973
974 Once the list of points is created, it can be plotted using the macro \tkzMacro{tkz-elements}{tkzDrawCoordinates}:
975
976 \begin{mybox}
977 \begin{verbatim}
978 \tkzDrawCoordinates[smooth,red](curve)
979 \end{verbatim}
980 \end{mybox}
981
982 Examples with the three types of conics
983 \begin{enumerate}
984
985
986 \item With parabola\\
987
988 $t$ is the abscissa of a point on the parabola, in an orthonormal frame of reference with origin $K$ and based on the directrix line and focal axis (major\_axis).
989
990
991
992 \begin{verbatim}
993 \directlua{
994 init_elements()
995 z.A = point(-2, -1)
996 z.B = point(4, 0)
997 z.F = point(1, 3)
998 L.dir = line(z.A, z.B)
999 CO.PA = conic(z.F, L.dir, 1)
1000 PA.curve = CO.PA:points(-4, 3, 50)
1001 z.K = CO.PA.K
1002 z.S = CO.PA.vertex
1003 L.AF = line(z.A, z.F)
1004 L.BF = line(z.B, z.F)
1005 z.U = intersection(CO.PA, L.AF)
1006 z.V = intersection(CO.PA, L.BF)
1007 part = CO.PA:points(-4, 3, 50)
1008 z.HU = L.dir:projection(z.U)
1009 z.HV = L.dir:projection(z.V)
1010 local ta = tkz.length(z.HU, z.K)
1011 local tb = tkz.length(z.HV, z.K)
1012 PA.curvered = CO.PA:points(-ta, tb, 20)}
1013 \begin{tikzpicture}
1014 \tkzGetNodes
1015 \tkzDrawCoordinates[smooth](PA.curve)
1016 \tkzDrawCoordinates[smooth,red,
1017 thick](PA.curvered)
1018 \tkzDrawLines(A,B K,F)
1019 \tkzDrawPoints(A,B,F,K,S,HU,HV)
1020 \tkzDrawPoints[red](U,V)
1021 \tkzLabelPoints[red](U,V)
1022 \tkzLabelPoints(A,B,F,K,S)
1023 \end{tikzpicture}
1024 \end{verbatim}
1025
1026
1027 \directlua{
1028 init_elements()
1029 z.A = point(-2, -1)
1030 z.B = point(4, 0)
1031 z.F = point(1, 3)
1032 L.dir = line(z.A, z.B)
1033 CO.PA = conic(z.F, L.dir, 1)
1034 PA.curve = CO.PA:points(-4, 3, 50)
1035 z.K = CO.PA.K
1036 z.S = CO.PA.vertex
1037 L.AF = line(z.A, z.F)
1038 L.BF = line(z.B, z.F)
1039 z.U = intersection(CO.PA, L.AF)
1040 z.V = intersection(CO.PA, L.BF)
1041 part = CO.PA:points(-4, 3, 50)
1042 z.HU = L.dir:projection(z.U)
1043 z.HV = L.dir:projection(z.V)
1044 local ta = tkz.length(z.HU, z.K)
1045 local tb = tkz.length(z.HV, z.K)
1046 curvered = CO.PA:points(-ta, tb, 20)}
1047 \begin{center}
1048 \begin{tikzpicture}
1049 \tkzGetNodes
1050 \tkzDrawCoordinates[smooth](PA.curve)
1051 \tkzDrawCoordinates[smooth,red,thick](part)
1052 \tkzDrawLines(A,B K,F)
1053 \tkzDrawPoints(A,B,F,K,S,HU,HV)
1054 \tkzDrawPoints[red](U,V)
1055 \tkzLabelPoints[red](U,V)
1056 \tkzLabelPoints(A,B,F,K,S)
1057 \end{tikzpicture}
1058 \end{center}
1059
1060
1061 \item With hyperbola
1062
1063 As with the parabola, the parameter \( t \) denotes the abscissa of a point on the hyperbola. The directrix is assumed to be the x-axis. To generate the second branch of the hyperbola, simply include the argument \code{"swap"}.
1064
1065
1066
1067 \directlua{
1068 init_elements()
1069 z.A = point(-2, -1)
1070 z.B = point(4, 0)
1071 L.AB = line(z.A, z.B)
1072 z.F = point(0, 3)
1073 CO.HY = conic(z.F, L.AB, 2)
1074 PA.curve = CO.HY:points(-5, 4, 50)
1075 PA.curveb = CO.HY:points(-5, 4, 50, "swap")
1076 z.K = CO.HY.K
1077 z.S = CO.HY.vertex
1078 z.O = CO.HY.center}
1079 \begin{center}
1080 \begin{tikzpicture}[scale=.75]
1081 \tkzGetNodes
1082 \tkzDrawCoordinates[smooth](PA.curve)
1083 \tkzDrawCoordinates[smooth](PA.curveb)
1084 \tkzDrawLines(A,B F,K)
1085 \tkzDrawPoints(A,B,F,K,S)
1086 \tkzLabelPoints(A,B,F,K,S)
1087 \end{tikzpicture}
1088 \end{center}
1089
1090 \begin{verbatim}
1091 \directlua{
1092 init_elements()
1093 z.A = point(-2, -1)
1094 z.B = point(4, 0)
1095 L.AB = line(z.A, z.B)
1096 z.F = point(0, 3)
1097 CO.HY = conic(z.F, L.AB, 2)
1098 curve = CO.HY:points(-5, 4, 50)
1099 curveb = CO.HY:points(-5, 4, 50, "swap")
1100 z.K = CO.HY.K
1101 z.S = CO.HY.vertex
1102 z.O = CO.HY.center}
1103 \begin{tikzpicture}
1104 \tkzGetNodes
1105 \tkzDrawCoordinates[smooth,cyan](curve)
1106 \tkzDrawCoordinates[smooth,cyan](curveb)
1107 \tkzDrawLines(A,B F,K)
1108 \tkzDrawPoints(A,B,F,K,S)
1109 \tkzLabelPoints(A,B,F,K,S)
1110 \end{tikzpicture}
1111 \end{verbatim}
1112
1113 \item With ellipse
1114
1115 This case differs slightly: the parameter \( t \) is a real number between \( 0 \) and \( 1 \), representing a fraction of the angle \( \widehat{MCV} \) measured in radians, where \( C \) is the center of the ellipse, \( V \) a vertex, and \( M \) a point on the ellipse.
1116 Thus, \( t = 0 \) and \( t = 1 \) correspond to the same vertex, \( t = 0.5 \) gives the opposite vertex, and \( t = 0.25 \) corresponds to a covertex.
1117
1118 The next example shows how to draw only a portion of the ellipse.
1119
1120 \vspace{1em}
1121
1122 \begin{verbatim}
1123 \directlua{
1124 init_elements()
1125 z.A = point(0, 0)
1126 z.B = point(4, 2)
1127 L.dir = line(z.A, z.B)
1128 z.F = point(2, 2)
1129 CO.EL = conic(z.F, L.dir, 0.8)
1130 PA.curve = CO.EL:points(0, 1, 50)
1131 PA.part = CO.EL:points(0.5, 0.75, 50)
1132 z.K = CO.EL.K
1133 z.C = CO.EL.center
1134 z.V = CO.EL.vertex
1135 z.M = CO.EL:point(0.3)}
1136 \begin{tikzpicture}
1137 \tkzGetNodes
1138 \tkzDrawLines(A,B K,F)
1139 \tkzDrawSegments(C,V C,M)
1140 \tkzDrawPoints(A,B,C,F,K,M,V)
1141 \tkzLabelPoints(A,B,C,F,K,M,V)
1142 \tkzDrawCoordinates[smooth](curve)
1143 \tkzDrawCoordinates[smooth,
1144 red,thick](part)
1145 \tkzMarkAngles[mark=||,size=.5](V,C,M)
1146 \end{tikzpicture}
1147 \end{verbatim}
1148
1149 \directlua{
1150 init_elements()
1151 z.A = point(0, 0)
1152 z.B = point(4, 2)
1153 L.dir = line(z.A, z.B)
1154 z.F = point(2, 2)
1155 CO.EL = conic(z.F, L.dir, 0.8)
1156 PA.curve = CO.EL:points(0, 1, 50)
1157 PA.part = CO.EL:points(0.5, 0.75, 50)
1158 z.K = CO.EL.K
1159 z.C = CO.EL.center
1160 z.V = CO.EL.vertex
1161 z.M = CO.EL:point(0.3)}
1162 \begin{center}
1163 \begin{tikzpicture}
1164 \tkzGetNodes
1165 \tkzDrawLines(A,B K,F)
1166 \tkzDrawSegments(C,V C,M)
1167 \tkzDrawPoints(A,B,C,F,K,M,V)
1168 \tkzLabelPoints(A,B,C,F,K,M,V)
1169 \tkzDrawCoordinates[smooth](PA.curve)
1170 \tkzDrawCoordinates[smooth,red,thick](PA.part)
1171 \tkzMarkAngles[mark=||,size=.5](V,C,M)
1172 \end{tikzpicture}
1173 \end{center}
1174 \end{enumerate}
1175
1176 \subsubsection{Method \tkzMeth{conic}{point(r)}}
1177
1178 This method defines a point on the conic. Unlike the \code{points} method, it takes only a single argument—the abscissa of the point.
1179 See also: Sections~\ref{ssub:method_conic_tangent_at}, \ref{ssub:parabola_construction}, and \ref{ssub:hyperbola_construction} for related uses.
1180
1181 \vspace{1em}
1182
1183 \subsubsection{Method \tkzMeth{conic}{tangent\_at}}
1184 \label{ssub:method_conic_tangent_at}
1185
1186 \directlua{
1187 init_elements()
1188 z.A = point(0, 0)
1189 z.B = point(4, -2)
1190 L.dir = line(z.A, z.B)
1191 z.F = point(2, 2)
1192 CO.EL = conic(z.F, L.dir, 0.8)
1193 CO.PA = conic(z.F, L.dir, 1)
1194 CO.HY = conic(z.F, L.dir, 1.2)
1195 PA.EL = CO.EL:points(0, 1, 50)
1196 PA.PA = CO.PA:points(-5, 5, 50)
1197 PA.HY = CO.HY:points(-5, 5, 50)
1198 z.X_1 = CO.EL:point(0.3)
1199 z.X_2 = CO.PA:point(3)
1200 z.X_3 = CO.HY:point(3)
1201 T1 = CO.EL:tangent_at(z.X_1)
1202 T2 = CO.PA:tangent_at(z.X_2)
1203 T3 = CO.HY:tangent_at(z.X_3)
1204 z.u1, z.v1 = T1:get()
1205 z.u2, z.v2 = T2:get()
1206 z.u3, z.v3 = T3:get()
1207 z.K = CO.PA.K}
1208 \begin{center}
1209 \begin{tikzpicture}[scale=.5]
1210 \tkzGetNodes
1211 \tkzDrawLines[cyan](A,B K,F)
1212 \tkzDrawCoordinates[smooth](PA.EL)
1213 \tkzDrawCoordinates[smooth](PA.PA)
1214 \tkzDrawCoordinates[smooth](PA.HY)
1215 \tkzDrawLines[add = 2 and 2,red](u1,v1 u2,v2 u3,v3)
1216 \tkzDrawPoints[red](X_1,X_2,X_3)
1217 \tkzDrawPoints(K,F)
1218 \tkzLabelPoints(K,F)
1219 \end{tikzpicture}
1220 \end{center}
1221
1222 \begin{verbatim}
1223 \directlua{
1224 init_elements()
1225 z.A = point(0, 0)
1226 z.B = point(4, -2)
1227 L.dir = line(z.A, z.B)
1228 z.F = point(2, 2)
1229 CO.EL = conic(z.F, L.dir, 0.8)
1230 CO.PA = conic(z.F, L.dir, 1)
1231 CO.HY = conic(z.F, L.dir, 1.2)
1232 PA.EL = CO.EL:points(0, 1, 50)
1233 PA.PA = CO.PA:points(-5, 5, 50)
1234 PA.HY = CO.HY:points(-5, 5, 50)
1235 z.X_1 = CO.EL:point(0.3)
1236 z.X_2 = CO.PA:point(3)
1237 z.X_3 = CO.HY:point(3)
1238 T1 = CO.EL:tangent_at(z.X_1)
1239 T2 = CO.PA:tangent_at(z.X_2)
1240 T3 = CO.HY:tangent_at(z.X_3)
1241 z.u1, z.v1 = T1:get()
1242 z.u2, z.v2 = T2:get()
1243 z.u3, z.v3 = T3:get()
1244 z.K = CO.PA.K}
1245 \begin{tikzpicture}
1246 \tkzGetNodes
1247 \tkzDrawLines[cyan](A,B K,F)
1248 \tkzDrawCoordinates[smooth](PA.EL)
1249 \tkzDrawCoordinates[smooth](PA.PA)
1250 \tkzDrawCoordinates[smooth](PA.HY)
1251 \tkzDrawLines[add = 2 and 2,red](u1,v1)
1252 \tkzDrawLines[add = 2 and 2,red](u2,v2)
1253 \tkzDrawLines[add = 2 and 2,red](u3,v3)
1254 \tkzDrawPoints[red](X_1,X_2,X_3)
1255 \tkzDrawPoints(K,F)
1256 \tkzLabelPoints(K,F)
1257 \end{tikzpicture}
1258 \end{verbatim}
1259
1260 \subsubsection{Method \tkzMeth{conic}{tangent\_from}}
1261 \label{ssub:method_conic_tangent_from}
1262
1263 This method computes the two tangents drawn from a given point to the conic.
1264 It returns the contact points of the tangents on the curve as two distinct points.
1265 This is useful for illustrating geometric constructions involving external tangents to ellipses, parabolas, or hyperbolas.
1266
1267 \vspace{1em}
1268
1269 \begin{verbatim}
1270 \directlua{
1271 init_elements()
1272 z.A = point(0, 0)
1273 z.B = point(2, -1)
1274 L.dir = line(z.A, z.B)
1275 z.F = point(2, 2)
1276 CO.EL = conic(z.F, L.dir, 0.8)
1277 CO.PA = conic(z.F, L.dir, 1)
1278 CO.HY = conic(z.F, L.dir, 1.2)
1279 PA.EL = CO.EL:points(0, 1, 50)
1280 PA.PA = CO.PA:points(-5, 6, 50)
1281 PA.HY = CO.HY:points(-5, 7, 50)
1282 R1, R2 = CO.EL:tangent_from(z.B)
1283 S1, S2 = CO.PA:tangent_from(z.B)
1284 T1, T2 = CO.HY:tangent_from(z.B)
1285 z.u1, z.v1 = R1:get()
1286 z.u2, z.v2 = R2:get()
1287 z.r1, z.s1 = S1:get()
1288 z.r2, z.s2 = S2:get()
1289 z.x1, z.y1 = T1:get()
1290 z.x2, z.y2 = T2:get()
1291 z.K = CO.PA.K}
1292 \begin{tikzpicture}
1293 \tkzGetNodes
1294 \tkzDrawLines[cyan](A,B K,F)
1295 \tkzDrawCoordinates[smooth](PA.EL)
1296 \tkzDrawCoordinates[smooth](PA.PA)
1297 \tkzDrawCoordinates[smooth](PA.HY)
1298 \tkzDrawLines[add = 0 and .25,red](B,v1 B,v2 B,s1 B,s2 B,y1 B,y2)
1299 \tkzDrawPoints[red](v1,v2,s1,s2,y1,y2)
1300 \tkzDrawPoints(K,F,B)
1301 \tkzLabelPoints(K,F,B)
1302 \end{tikzpicture}
1303 \end{verbatim}
1304
1305 \directlua{
1306 init_elements()
1307 z.A = point(0, 0)
1308 z.B = point(2, -1)
1309 L.dir = line(z.A, z.B)
1310 z.F = point(2, 2)
1311 CO.EL = conic(z.F, L.dir, 0.8)
1312 CO.PA = conic(z.F, L.dir, 1)
1313 CO.HY = conic(z.F, L.dir, 1.2)
1314 PA.EL = CO.EL:points(0, 1, 50)
1315 PA.PA = CO.PA:points(-5, 6, 50)
1316 PA.HY = CO.HY:points(-5, 7, 50)
1317 R1, R2 = CO.EL:tangent_from(z.B)
1318 S1, S2 = CO.PA:tangent_from(z.B)
1319 T1, T2 = CO.HY:tangent_from(z.B)
1320 z.u1, z.v1 = R1:get()
1321 z.u2, z.v2 = R2:get()
1322 z.r1, z.s1 = S1:get()
1323 z.r2, z.s2 = S2:get()
1324 z.x1, z.y1 = T1:get()
1325 z.x2, z.y2 = T2:get()
1326 z.K = CO.PA.K}
1327 \begin{center}
1328 \begin{tikzpicture}[scale =.75]
1329 \tkzGetNodes
1330 \tkzDrawLines[cyan](A,B K,F)
1331 \tkzDrawCoordinates[smooth](PA.EL)
1332 \tkzDrawCoordinates[smooth](PA.PA)
1333 \tkzDrawCoordinates[smooth](PA.HY)
1334 \tkzDrawLines[add = 0 and .25,red](B,v1 B,v2 B,s1 B,s2 B,y1 B,y2)
1335 \tkzDrawPoints[red](v1,v2,s1,s2,y1,y2)
1336 \tkzDrawPoints(K,F,B)
1337 \tkzLabelPoints(K,F,B)
1338 \end{tikzpicture}
1339 \end{center}
1340
1341 \subsubsection{Method \tkzMeth{conic}{point}}
1342
1343 This method is similar to the \code{point} method found in other classes, with specific differences depending on the conic type.
1344 The parameter \( t \) typically represents a fraction of a given distance and usually lies between \( 0 \) and \( 1 \). However, this interpretation does not apply to parabolas and hyperbolas: in these cases, \( t \) corresponds to the abscissa on the directrix of a point on the curve.
1345
1346 For ellipses, \( t \) has the same interpretation as in the case of circles: it defines a point on the associated principal circle.
1347 The corresponding point on the ellipse is then obtained by an affine transformation with ratio \( \frac{b}{a} \), where \( a \) and \( b \) are the semi-major and semi-minor axes, respectively.
1348
1349 See also Section~\ref{ssub:method_conic_tangent_at} for related information.
1350
1351 A few remarks on the following example: it illustrates how an ellipse can be constructed from its principal circle via an affinity.
1352 For instance, the segment \( HQ' = \frac{b}{a} HQ \), and the angle relation \( \tan(\beta) = \frac{b}{a} \tan(\alpha) \) also holds.
1353
1354 \vspace{1em}
1355
1356 \begin{minipage}{.5\textwidth}
1357 \begin{verbatim}
1358 \directlua{
1359 init_elements()
1360 z.Fb = point(3, 0)
1361 z.Fa = point(-3, 2)
1362 local c = tkz.length(z.Fa, z.Fb) / 2
1363 local a = 4
1364 local b = math.sqrt(a ^ 2 - c ^ 2)
1365 local e = c / a
1366 L.FaFb = line(z.Fa, z.Fb)
1367 z.C = L.FaFb.mid
1368 L.CFb = line(z.C, z.Fb)
1369 z.K = L.CFb:report(a ^ 2 / c)
1370 z.Ko = ortho_from_(z.K, z.K, z.Fb)
1371 L.dir = line(z.K, z.Ko)
1372 CO.EL = conic(z.Fb, L.dir, e)
1373 PA.curve = CO.EL:points(0, 1, 100)
1374 z.X = CO.EL.vertex
1375 C.X = circle(z.C, z.X)
1376 z.Q = C.X:point(0.15)
1377 z.H = L.FaFb:projection(z.Q)
1378 z.Qp = L.FaFb:affinity(L.FaFb:
1379 ortho_from(z.C), b / a, z.Q)}
1380 \begin{tikzpicture}
1381 \tkzGetNodes
1382 \tkzDrawCoordinates[smooth](PA.curve)
1383 \tkzDrawLines(Fa,Fb K,Ko)
1384 \tkzDrawLines[add = 2 and 2](K,Ko)
1385 \tkzDrawCircles(C,Q)
1386 \tkzDrawSegments[dashed](C,Q C,Q' H,Q)
1387 \tkzDrawPoints(Fa,Fb,C,X,Q,Q',H)
1388 \tkzLabelPoints(Fa,Fb,C,X,Q,Q',H)
1389 \tkzLabelAngle(Fb,C,Q'){$\beta$}
1390 \tkzMarkAngle[size=.8](Fb,C,Q')
1391 \tkzLabelAngle[pos=1.5](Fb,C,Q){$\alpha$}
1392 \tkzMarkAngle[size=1.3](Fb,C,Q)
1393 \end{tikzpicture}
1394 \end{verbatim}
1395 \end{minipage}
1396 \begin{minipage}{.5\textwidth}
1397 \directlua{
1398 init_elements()
1399 z.Fb = point(3, 0)
1400 z.Fa = point(-3, 2)
1401 local c = tkz.length(z.Fa, z.Fb) / 2
1402 local a = 4
1403 local b = math.sqrt(a ^ 2 - c ^ 2)
1404 local e = c / a
1405 L.FaFb = line(z.Fa, z.Fb)
1406 z.C = L.FaFb.mid
1407 L.CFb = line(z.C, z.Fb)
1408 z.K = L.CFb:report(a ^ 2 / c)
1409 z.Ko = ortho_from_(z.K, z.K, z.Fb)
1410 L.dir = line(z.K, z.Ko)
1411 CO.EL = conic(z.Fb, L.dir, e)
1412 PA.curve = CO.EL:points(0, 1, 100)
1413 z.X = CO.EL.vertex
1414 C.X = circle(z.C, z.X)
1415 z.Q = C.X:point(0.15)
1416 z.H = L.FaFb:projection(z.Q)
1417 z.Qp = L.FaFb:affinity(L.FaFb:
1418 ortho_from(z.C), b / a, z.Q)}
1419
1420 \begin{center}
1421 \begin{tikzpicture}[scale=.75]
1422 \tkzGetNodes
1423 \tkzDrawCoordinates[smooth](PA.curve)
1424 \tkzDrawLines(Fa,Fb K,Ko)
1425 \tkzDrawLines[add = 2 and 2](K,Ko)
1426 \tkzDrawCircles(C,Q)
1427 \tkzDrawSegments[dashed](C,Q C,Q' H,Q)
1428 \tkzDrawPoints(Fa,Fb,C,X,Q,Q',H)
1429 \tkzLabelPoints(Fa,Fb,C,X,Q,Q',H)
1430 \tkzLabelAngle(Fb,C,Q'){$\beta$}
1431 \tkzMarkAngle[size=.8](Fb,C,Q')
1432 \tkzLabelAngle[pos=1.5](Fb,C,Q){$\alpha$}
1433 \tkzMarkAngle[size=1.3](Fb,C,Q)
1434 \end{tikzpicture}
1435 \end{center}
1436 \end{minipage}
1437
1438 \subsubsection{Method \tkzMeth{conic}{position(pt[,EPS])}}
1439 \label{ssub:method_conic_position}
1440
1441 This method determines the relative position of a point with respect to a conic.
1442
1443 \medskip
1444
1445 It takes a point \code{pt} and an optional tolerance \code{EPS}.
1446 If omitted, the global tolerance \code{tkz.epsilon} is used.
1447
1448 \medskip
1449
1450 The method returns one of the following strings:
1451 \begin{itemize}
1452 \item \code{"IN"} — the point lies in the interior region;
1453 \item \code{"ON"} — the point lies on the conic (within tolerance);
1454 \item \code{"OUT"} — the point lies in the exterior region.
1455 \end{itemize}
1456
1457 \medskip
1458
1459 The behaviour depends on the conic type:
1460 \begin{itemize}
1461 \item Ellipse (\(e < 1\)) — interior region is bounded;
1462 \item Parabola (\(e = 1\)) — interior is the convex side;
1463 \item Hyperbola (\(e > 1\)) — interior corresponds to the region
1464 between the two branches.
1465 \end{itemize}
1466
1467 \medskip
1468
1469 \noindent\texttt{Compatibility note: }
1470 If a boolean test is required (for example in legacy code),
1471 one may use:
1472 \[
1473 \texttt{CO:position(P) ~= "OUT"}
1474 \]
1475 which is true for both \code{"IN"} and \code{"ON"}.
1476
1477 \vspace{1em}
1478
1479 \texttt{Example: }
1480
1481
1482 \begin{minipage}{.50\textwidth}
1483 \begin{verbatim}
1484 \directlua{
1485 init_elements()
1486 z.A = point(0,0)
1487 z.B = point(4,-2)
1488 L.dir = line(z.A,z.B)
1489 z.F = point(2,2)
1490
1491 CO.EL = conic(z.F, L.dir, 0.8)
1492 CO.PA = conic(z.F, L.dir, 1.0)
1493 CO.HY = conic(z.F, L.dir, 1.2)
1494
1495 PA.EL = CO.EL:points(0,1,60)
1496 PA.PA = CO.PA:points(-5,5,60)
1497 PA.HY = CO.HY:points(-5,5,60)
1498
1499 z.L = point(-2,4)
1500 z.M = point(-1,5)
1501 z.N = point(0,6)
1502 z.O = point(1,7)
1503
1504 Lel = CO.EL:position(z.L)
1505 Lpa = CO.PA:position(z.L)
1506 Lhy = CO.HY:position(z.L)
1507
1508 Mel = CO.EL:position(z.M)
1509 Mpa = CO.PA:position(z.M)
1510 Mhy = CO.HY:position(z.M)
1511
1512 Nel = CO.EL:position(z.N)
1513 Npa = CO.PA:position(z.N)
1514 Nhy = CO.HY:position(z.N)
1515
1516 Oel = CO.EL:position(z.O)
1517 Opa = CO.PA:position(z.O)
1518 Ohy = CO.HY:position(z.O)
1519 }
1520 \end{verbatim}
1521 \end{minipage}
1522 \begin{minipage}{.50\textwidth}
1523 \directlua{
1524 init_elements()
1525 z.A = point(0,0)
1526 z.B = point(4,-2)
1527 L.dir = line(z.A,z.B)
1528 z.F = point(2,2)
1529
1530 CO.EL = conic(z.F, L.dir, 0.8)
1531 CO.PA = conic(z.F, L.dir, 1.0)
1532 CO.HY = conic(z.F, L.dir, 1.2)
1533
1534 PA.EL = CO.EL:points(0,1,60)
1535 PA.PA = CO.PA:points(-5,5,60)
1536 PA.HY = CO.HY:points(-5,5,60)
1537
1538 z.L = point(-2,4)
1539 z.M = point(-1,5)
1540 z.N = point(0,6)
1541 z.O = point(1,7)
1542
1543 Lel = CO.EL:position(z.L)
1544 Lpa = CO.PA:position(z.L)
1545 Lhy = CO.HY:position(z.L)
1546
1547 Mel = CO.EL:position(z.M)
1548 Mpa = CO.PA:position(z.M)
1549 Mhy = CO.HY:position(z.M)
1550
1551 Nel = CO.EL:position(z.N)
1552 Npa = CO.PA:position(z.N)
1553 Nhy = CO.HY:position(z.N)
1554
1555 Oel = CO.EL:position(z.O)
1556 Opa = CO.PA:position(z.O)
1557 Ohy = CO.HY:position(z.O)
1558 }
1559 \begin{center}
1560 \begin{tikzpicture}[scale=.6]
1561 \tkzGetNodes
1562 \tkzDrawCoordinates[smooth](PA.EL)
1563 \tkzDrawCoordinates[smooth](PA.PA)
1564 \tkzDrawCoordinates[smooth](PA.HY)
1565 \tkzDrawPoints(L,M,N,O)
1566
1567 \tkzLabelPoint(L){$L$:(\tkzUseLua{Lel};\tkzUseLua{Lpa};\tkzUseLua{Lhy})}
1568 \tkzLabelPoint(M){$M$:(\tkzUseLua{Mel};\tkzUseLua{Mpa};\tkzUseLua{Mhy})}
1569 \tkzLabelPoint(N){$N$:(\tkzUseLua{Nel};\tkzUseLua{Npa};\tkzUseLua{Nhy})}
1570 \tkzLabelPoint(O){$O$:(\tkzUseLua{Oel};\tkzUseLua{Opa};\tkzUseLua{Ohy})}
1571 \end{tikzpicture}
1572 \end{center}
1573 \end{minipage}
1574
1575
1576 \subsubsection{Method \tkzMeth{conic}{in\_out}; Deprecated}
1577 \label{ssub:method_conic_in_out}
1578
1579 This method is kept for backward compatibility.
1580
1581
1582 \subsubsection{Method \tkzMeth{conic}{orthoptic}}
1583 \label{ssub:method_conic_orthoptic}
1584
1585 In curve geometry, the orthoptic of a conic is the set of points from which two tangents to the curve intersect at a right angle.
1586 For a parabola, the orthoptic is simply the directrix.
1587 For ellipses and hyperbolas, the orthoptic is a circle—but in the case of the hyperbola, this holds only if the eccentricity lies between \( 1 \) and \( \sqrt{2} \).
1588 \footnote{When the eccentricity equals \( \sqrt{2} \), the hyperbola is rectangular (equilateral). In an orthonormal coordinate system, its asymptotes then have equations \( y = x \) and \( y = -x \).}
1589
1590 \vspace{1em}
1591
1592 \begin{minipage}{.5\textwidth}
1593 \begin{verbatim}
1594 \directlua{
1595 init_elements()
1596 z.A = point(0, 1)
1597 z.B = point(4, 3)
1598 z.F = point(2, 6)
1599 L.AB = line(z.A, z.B)
1600 CO.PA = conic(z.F, L.AB, 1)
1601 PA.curve = CO.PA:points(-5, 5, 50)
1602 z.K = CO.PA.K
1603 z.S = CO.PA.vertex
1604 z.M = CO.PA:point(-3)
1605 z.H = CO.PA.directrix:projection(z.M)
1606 L.FH = line(z.F, z.H)
1607 L.med = L.FH:mediator()
1608 z.P = intersection(L.AB, L.med)
1609 z.N = CO.PA:tangent_from(z.P).pb
1610 D = CO.PA:orthoptic()
1611 z.v = D:point(0.75)
1612 T1, T2 = CO.PA:tangent_from(z.v)
1613 z.t1 = T1.pb
1614 z.t2 = T2.pb}
1615 \begin{tikzpicture}
1616 \tkzGetNodes
1617 \tkzDrawCoordinates[smooth,
1618 thick,purple](PA.curve)
1619 \tkzDrawLines[add = 0 and .2](v,t1
1620 v,t2 P,N)
1621 \tkzDrawLines[add = .5 and .5](A,B
1622 M,P K,F)
1623 \tkzDrawSegments(M,H H,F F,M)
1624 \tkzDrawPoints(F,K,P,M,H,v,t1,t2,S,N)
1625 \tkzLabelPoints(K,P,M,H,S)
1626 \tkzLabelPoints[right](F,N)
1627 \tkzMarkAngles[mark=||](H,M,P P,M,F)
1628 \tkzMarkSegments[mark=x](H,M M,F)
1629 \tkzMarkSegments[mark=|](F,S K,S)
1630 \end{tikzpicture}
1631 \end{verbatim}
1632 \end{minipage}
1633 \begin{minipage}{.5\textwidth}
1634 \directlua{
1635 init_elements()
1636 z.A = point(0, 1)
1637 z.B = point(4, 3)
1638 z.F = point(2, 6)
1639 L.AB = line(z.A, z.B)
1640 CO.PA = conic(z.F, L.AB, 1)
1641 PA.curve = CO.PA:points(-5, 5, 50)
1642 z.K = CO.PA.K
1643 z.S = CO.PA.vertex
1644 z.M = CO.PA:point(-3)
1645 z.H = CO.PA.directrix:projection(z.M)
1646 L.FH = line(z.F, z.H)
1647 L.med = L.FH:mediator()
1648 z.P = intersection(L.AB, L.med)
1649 z.N = CO.PA:tangent_from(z.P).pb
1650 D = CO.PA:orthoptic()
1651 z.v = D:point(0.75)
1652 T1, T2 = CO.PA:tangent_from(z.v)
1653 z.t1 = T1.pb
1654 z.t2 = T2.pb}
1655 \begin{center}
1656 \begin{tikzpicture}[scale =.75]
1657 \tkzGetNodes
1658 \tkzDrawCoordinates[smooth,thick,purple](PA.curve)
1659 \tkzDrawLines[add = 0 and .2](v,t1 v,t2 P,N)
1660 \tkzDrawLines[add = .5 and .5](A,B M,P K,F)
1661 \tkzDrawSegments(M,H H,F F,M)
1662 \tkzDrawPoints(F,K,P,M,H,v,t1,t2,S,N)
1663 \tkzLabelPoints(K,P,M,H,S)
1664 \tkzLabelPoints[right](F,N)
1665 \tkzMarkAngles[mark=||](H,M,P P,M,F)
1666 \tkzMarkSegments[mark=x](H,M M,F)
1667 \tkzMarkSegments[mark=|](F,S K,S)
1668 \end{tikzpicture}
1669 \end{center}
1670 \end{minipage}
1671
1672 \subsubsection{Method \tkzMeth{conic}{path(pt, pt, nb, mode, dir)}}
1673 \label{ssub:conic_path}
1674
1675 The \tkzClass{conic} class provides a method \tkzMeth{conic}{path} that creates a
1676 \tkzClass{path} object representing a portion of the conic between two given
1677 points (an arc of conic).
1678
1679 \medskip
1680 \texttt{Syntax:}
1681 \verb|PA.arc = CO.myconic:path(zA, zB, 40, "swap")|
1682
1683 \texttt{Arguments:}
1684
1685 \begin{itemize}
1686 \item \code{za}, \code{zb} — two points lying on the conic.
1687 \item \code{nb} — number of interpolation steps (default: 20).
1688 \item \code{mode} — optional string:
1689 \begin{itemize}
1690 \item omitted or \code{"direct"} (default): traces the shortest arc (for ellipses).
1691 \item \code{"swap"}: selects the complementary arc (other part of the ellipse).
1692 \end{itemize}
1693 \item \code{dir} — optional orientation for ambiguous cases
1694
1695 In most cases, the points \code{za} and \code{zb} determine a unique arc of the conic.
1696 However, when the two points are \emph{opposite} with respect to the center (for instance, on an ellipse),
1697 two different arcs of equal length exist.
1698 In such cases, the optional argument can be used to select the desired direction:
1699
1700 \begin{itemize}
1701 \item \code{"ccw"} (\emph{counterclockwise}) — the arc is traced in the direct, or positive, direction.
1702 \item \code{"cw"} (\emph{clockwise}) — the arc is traced in the opposite, or negative, direction.
1703 \end{itemize}
1704
1705 In general use, this parameter can be omitted.
1706 \end{itemize}
1707
1708 \medskip
1709 \texttt{Details:}
1710
1711 Internally, the method computes the conic parameter $t$ at \code{za} and \code{zb} using \tkzMeth{conic}{get\_t\_from\_point(z)}. For ellipses, this parameter is normalized in [0,1) (one turn). For parabolas and hyperbolas, it is not periodic.
1712
1713 A linear interpolation of $t$ produces intermediate points on the conic:
1714 \[
1715 t_i = t_a + \frac{i}{nb}(t_b - t_a)
1716 \]
1717
1718 For ellipses specifically:
1719 \begin{itemize}
1720 \item the angle/parameter is taken modulo $1$;
1721 \item in \code{"direct"} mode, the interpolation follows the shortest arc
1722 between the two points;
1723 \item in \code{"swap"} mode, the complementary arc is used
1724 (the same endpoints, but the other part of the ellipse);
1725 \item if the points are exactly opposite ($\Delta t = \pm 0.5$), the option
1726 \code{dir = "cw"} or \code{"ccw"} can be used to choose the direction.
1727 \end{itemize}
1728
1729 \medskip
1730
1731 \begin{mybox}
1732 \begin{verbatim}
1733 -- Example: parabola
1734 C = conic(z.F, L.directrix, 1)
1735 PA.arc = C:path(z.A, z.B, 100)
1736 \end{verbatim}
1737 \end{mybox}
1738
1739 \begin{mybox}
1740 \begin{verbatim}
1741 -- Example: ellipse, complementary arc
1742 E = conic(z.F1, z.F2, 0.6) -- an ellipse
1743 PA.arc1 = E:path(z.A, z.B, 80, "direct") -- shortest arc
1744 PA.arc2 = E:path(z.A, z.B, 80, "swap") -- other arc
1745 \end{verbatim}
1746 \end{mybox}
1747
1748 To draw the resulting path with TikZ:
1749 \begin{mybox}
1750 \begin{verbatim}
1751 \tkzDrawCoordinates[smooth]
1752 \end{verbatim}
1753 \end{mybox}
1754
1755
1756 \begin{tkzexample}[latex=.35\textwidth]
1757 \directlua{
1758 init_elements()
1759 z.A = point(0, 0)
1760 z.B = point(4, 2)
1761 L.dir = line(z.A, z.B)
1762 z.F = point(2, 2)
1763 CO.EL = conic(z.F, L.dir, 0.8)
1764 PA.curve = CO.EL:points(0, 1, 50)
1765 z.M = CO.EL:point(0.95)
1766 z.N = CO.EL:point(0.15)
1767 z.P = CO.EL:point(0.4)
1768 z.Q = CO.EL:point(0.7)
1769 PA.parta = CO.EL:path(z.M, z.N, 100, "swap")
1770 PA.partb = CO.EL:path(z.P, z.Q, 100)
1771 L.PM = line(z.P, z.M)
1772 L.QN = line(z.Q, z.N)
1773 z.I = intersection(L.PM, L.QN)
1774 L.NI = line(z.N, z.I)
1775 L.IM = line(z.I, z.M)
1776 L.IP = line(z.I, z.P)
1777 L.QI = line(z.Q, z.I)
1778 PA.zone1 = CO.EL:path(z.M, z.N, 50, "swap")
1779 + L.NI:path(2) + L.IM:path(2)
1780 PA.zone2 = CO.EL:path(z.P, z.Q, 50, "swap")
1781 + L.QI:path(2) + L.IP:path(2)
1782 }
1783 \begin{tikzpicture}[ scale = 1.2]
1784 \tkzGetNodes
1785 \tkzDrawCoordinates[fill = green!10](PA.zone1)
1786 \tkzDrawCoordinates[fill = green!10](PA.zone2)
1787 \tkzDrawCoordinates[smooth](PA.curve)
1788 \tkzDrawCoordinates[smooth,red,thick](PA.partb)
1789 \tkzDrawCoordinates[smooth,blue,thick](PA.parta)
1790 \tkzDrawSegments(P,M Q,N)
1791 \tkzDrawPoints(M,N,P,Q,I)
1792 \end{tikzpicture}
1793 \end{tkzexample}
1794
1795
1796 \texttt{Example with parabola}
1797
1798 This example shows the case of a parabola. It would be the same for a hyperbola ( the "swap" option is not yet authorized).
1799
1800 \begin{tkzexample}[latex=.35\textwidth]
1801 \directlua{
1802 init_elements()
1803 z.A = point(0, 0)
1804 z.B = point(4, 2)
1805 L.dir = line(z.A, z.B)
1806 z.F = point(2, 2)
1807 CO.EL = conic(z.F, L.dir, 1)
1808 PA.curve = CO.EL:points(-2, 2, 50)
1809 z.P = CO.EL:point(-1.75)
1810 z.Q = CO.EL:point(1.5)
1811 PA.part = CO.EL:path(z.P, z.Q, 100)
1812 }
1813 \begin{tikzpicture}
1814 \tkzGetNodes
1815 \tkzDrawCoordinates[smooth](PA.curve)
1816 \tkzDrawCoordinates[smooth,red,thick](PA.part)
1817 \tkzDrawPoints(P,Q)
1818 \end{tikzpicture}
1819 \end{tkzexample}
1820
1821
1822
1823 \subsubsection{Intersection: Line and Conic}
1824
1825 Additional details can be found in Section~\ref{sec:intersections}, in particular Subsection~\ref{sub:line_conic}.
1826
1827 The following example illustrates how to compute the intersection between a straight line and each of the three types of conics.
1828 As with other intersection methods, there is no need to specify the type of conic explicitly—the package will determine the appropriate class automatically.
1829 Currently, intersections are only supported between straight lines and conics.
1830
1831 \vspace{1em}
1832
1833 \begin{minipage}{.55\textwidth}
1834 \begin{verbatim}
1835 \directlua{
1836 init_elements()
1837 z.A = point(0, 0)
1838 z.B = point(4, -2)
1839 L.dir = line(z.A, z.B)
1840 z.F = point(2, 2)
1841 CO.EL = conic(z.F, L.dir, 0.8)
1842 CO.PA = conic(z.F, L.dir, 1)
1843 CO.HY = conic(z.F, L.dir, 1.2)
1844 PA.EL = CO.EL:points(0, 1, 50)
1845 PA.PA = CO.PA:points(-5, 5, 50)
1846 PA.HY = CO.HY:points(-5, 5, 50)
1847 z.K = CO.EL.K
1848 z.u, z.v = CO.EL.major_axis:get()
1849 z.x = L.dir:report(-3, z.K)
1850 z.y = L.dir:report(3, z.K)
1851 z.r = point(0, 4)
1852 z.s = point(4, 1)
1853 L.rs = line(z.r, z.s)
1854 z.u_1, z.u_2 = intersection(L.rs, CO.EL)
1855 z.v_1, z.v_2 = intersection(L.rs, CO.PA)
1856 z.w_1, z.w_2 = intersection(L.rs, CO.HY)}
1857 \begin{tikzpicture}
1858 \tkzGetNodes
1859 \tkzDrawCoordinates[smooth](PA.EL)
1860 \tkzDrawCoordinates[smooth](PA.PA)
1861 \tkzDrawCoordinates[smooth](PA.HY)
1862 \tkzDrawLines[add =.5 and .5](r,s u,v x,y)
1863 \tkzDrawPoints[red](u_1,u_2,v_2,v_1,w_1,w_2)
1864 \end{tikzpicture}
1865 \end{verbatim}
1866 \end{minipage}
1867 \begin{minipage}{.45\textwidth}
1868 \directlua{
1869 init_elements()
1870 z.A = point(0, 0)
1871 z.B = point(4, -2)
1872 L.dir = line(z.A, z.B)
1873 z.F = point(2, 2)
1874 CO.EL = conic(z.F, L.dir, 0.8)
1875 CO.PA = conic(z.F, L.dir, 1)
1876 CO.HY = conic(z.F, L.dir, 1.2)
1877 PA.EL = CO.EL:points(0, 1, 50)
1878 PA.PA = CO.PA:points(-5, 5, 50)
1879 PA.HY = CO.HY:points(-5, 5, 50)
1880 z.K = CO.EL.K
1881 z.u, z.v = CO.EL.major_axis:get()
1882 z.x = L.dir:report(-3, z.K)
1883 z.y = L.dir:report(3, z.K)
1884 z.r = point(0, 4)
1885 z.s = point(4, 1)
1886 L.rs = line(z.r, z.s)
1887 z.u_1, z.u_2 = intersection(L.rs, CO.EL)
1888 z.v_1, z.v_2 = intersection(L.rs, CO.PA)
1889 z.w_1, z.w_2 = intersection(L.rs, CO.HY)}
1890 \begin{center}
1891 \begin{tikzpicture}[scale=.5]
1892 \tkzGetNodes
1893 \tkzDrawCoordinates[smooth](PA.EL)
1894 \tkzDrawCoordinates[smooth](PA.PA)
1895 \tkzDrawCoordinates[smooth](PA.HY)
1896 \tkzDrawLines[add =.5 and .5](r,s u,v x,y)
1897 \tkzDrawPoints[red](u_1,u_2,v_2,v_1,w_1,w_2)
1898 \end{tikzpicture}
1899 \end{center}
1900 \end{minipage}
1901
1902 \subsubsection{Useful Tools}
1903
1904 This section presents utility functions for retrieving key geometric elements of a conic: its focus, directrix, and eccentricity.
1905
1906
1907 \subsubsection{Function \tkzFct{math}{PA\_dir}}
1908 \label{ssub:pa_dir}
1909
1910 This function computes the directrix of a parabola, given its focus and two points on the curve.
1911 The method involves constructing circles centered at the two given points and passing through the focus.
1912 The common tangents to these two circles correspond to the possible directrices of the parabola—two solutions exist.
1913
1914 To obtain the second solution, simply reverse the order of the return values: replace \verb|_, L.dir| with \verb|L.dir, _|.
1915
1916 \vspace{1em}
1917
1918
1919 \begin{minipage}{.5\textwidth}
1920 \begin{verbatim}
1921 \directlua{
1922 init_elements()
1923 z.A = point(0, 1)
1924 z.B = point(5, 2)
1925 z.F = point(2, -1)
1926 _, L.dir = PA_dir(z.F, z.A, z.B)
1927 CO.PA = conic(z.F, L.dir, 1)
1928 PA.curve = CO.PA:points(-5, 5, 50)
1929 z.T, z.Tp = L.dir:get()}
1930 \begin{tikzpicture}[scale = .5]
1931 \tkzGetNodes
1932 \tkzDrawCoordinates[smooth,
1933 cyan](PA.curve)
1934 \tkzDrawCircles(A,F B,F)
1935 \tkzDrawPoints(A,B,F,T,T')
1936 \tkzDrawLine(T,T')
1937 \tkzLabelPoints(A,B,F,T,T')
1938 \end{tikzpicture}
1939 \end{verbatim}
1940 \end{minipage}
1941 \begin{minipage}{.5\textwidth}
1942 \directlua{
1943 init_elements()
1944 z.A = point(0, 1)
1945 z.B = point(5, 2)
1946 z.F = point(2, -1)
1947 _, L.dir = PA_dir(z.F, z.A, z.B)
1948 CO.PA = conic(z.F, L.dir, 1)
1949 PA.curve = CO.PA:points(-5, 5, 50)
1950 z.T, z.Tp = L.dir:get()}
1951 \begin{center}
1952 \begin{tikzpicture}[scale = .5]
1953 \tkzGetNodes
1954 \tkzDrawCoordinates[smooth,cyan](PA.curve)
1955 \tkzDrawCircles(A,F B,F)
1956 \tkzDrawPoints(A,B,F,T,T')
1957 \tkzDrawLine(T,T')
1958 \tkzLabelPoints(A,B,F,T,T')
1959 \end{tikzpicture}
1960 \end{center}
1961 \end{minipage}
1962
1963 \subsubsection{Function \tkzFct{math}{PA\_focus}}
1964 \label{ssub:_igfct_math_pa__focus}
1965
1966 This function computes the focus of a parabola, given its directrix and two points on the curve.
1967
1968 The method is based on constructing two circles, each centered at one of the given points and tangent to the directrix.
1969 If such a construction is possible, the focus corresponds to one of the intersection points of these two circles.
1970
1971 \vspace{1em}
1972
1973 \begin{minipage}{.5\textwidth}
1974 \begin{verbatim}
1975 \directlua{
1976 init_elements()
1977 z.A = point(0, 1)
1978 z.B = point(4, 2)
1979 z.u = point(2, -1)
1980 z.v = point(-2, 0)
1981 L.dir = line(z.u, z.v)
1982 z.hA = L.dir:projection(z.A)
1983 z.hB = L.dir:projection(z.B)
1984 z.F, z.G = PA_focus(L.dir, z.A, z.B)
1985 CO.PA = conic(z.F, L.dir, 1)
1986 PA.curve = CO.PA:points(-5, 5, 50)}
1987 \begin{tikzpicture}
1988 \tkzGetNodes
1989 \tkzDrawCoordinates[smooth,cyan](PA.curve)
1990 \tkzDrawCircles(A,hA B,hB)
1991 \tkzDrawLines(u,v)
1992 \tkzDrawPoints(A,B,u,v,hA,hB,F,G)
1993 \tkzLabelPoints(A,B,F,G,u,v)
1994 \end{tikzpicture}
1995 \end{verbatim}
1996 \end{minipage}
1997 \begin{minipage}{.5\textwidth}
1998 \directlua{
1999 init_elements()
2000 z.A = point(0, 1)
2001 z.B = point(4, 2)
2002 z.u = point(2, -1)
2003 z.v = point(-2, 0)
2004 L.dir = line(z.u, z.v)
2005 z.hA = L.dir:projection(z.A)
2006 z.hB = L.dir:projection(z.B)
2007 z.F, z.G = PA_focus(L.dir, z.A, z.B)
2008 CO.PA = conic(z.F, L.dir, 1)
2009 curve = CO.PA:points(-5, 5, 50)}
2010 \begin{center}
2011 \begin{tikzpicture}[scale = .75]
2012 \tkzGetNodes
2013 \tkzDrawCoordinates[smooth,cyan](curve)
2014 \tkzDrawCircles(A,hA B,hB)
2015 \tkzDrawLines(u,v)
2016 \tkzDrawPoints(A,B,u,v,hA,hB,F,G)
2017 \tkzLabelPoints(A,B,F,G,u,v)
2018 \end{tikzpicture}
2019 \end{center}
2020 \end{minipage}
2021
2022 \subsubsection{Function \tkzFct{math}{HY\_bifocal}}
2023 \label{ssub:_igfct_math_hy__bifocal}
2024
2025 For the hyperbola, this is currently the only available tool, and it relies on the bifocal definition.
2026 The inputs are the two foci, along with either the semi-major axis \( a \) (i.e., the distance from the center to a vertex), or a point lying on the hyperbola.
2027
2028 The method proceeds by applying standard formulas that characterize a hyperbola to compute its main geometric attributes.
2029
2030 \vspace{1em}
2031
2032 \begin{minipage}{.5\textwidth}
2033 \begin{verbatim}
2034 \directlua{
2035 init_elements()
2036 z.F = point(1, -1)
2037 z.G = point(4, 3)
2038 z.M = point(6, 2)
2039 z.C = tkz.midpoint(z.F,z.G)
2040 CO.HY = conic(HY_bifocal(z.G, z.F, z.M))
2041 PA.curve = CO.HY:points(-3, 3, 50)
2042 z.K = CO.HY.K
2043 PA.curveb = CO.HY:points(-3, 3, 50, "swap")}
2044 \begin{tikzpicture}[scale = .5]
2045 \tkzGetNodes
2046 \tkzDrawCoordinates[smooth,red](PA.curve)
2047 \tkzDrawCoordinates[smooth,red](PA.curveb)
2048 \tkzDrawSegments[dashed](M,F M,G)
2049 \tkzDrawLine(F,G)
2050 \tkzDrawPoints[red](M)
2051 \tkzDrawPoints(C,F,G,K)
2052 \tkzLabelPoints(C,F,G,K)
2053 \end{tikzpicture}
2054 \end{verbatim}
2055 \end{minipage}
2056 \begin{minipage}{.5\textwidth}
2057 \directlua{
2058 init_elements()
2059 z.F = point(1, -1)
2060 z.G = point(4, 3)
2061 z.M = point(6, 2)
2062 z.C = tkz.midpoint(z.F,z.G)
2063 CO.HY = conic(HY_bifocal(z.G, z.F, z.M))
2064 PA.curve = CO.HY:points(-3, 3, 50)
2065 z.K = CO.HY.K
2066 PA.curveb = CO.HY:points(-3, 3, 50, "swap")}
2067 \begin{center}
2068 \begin{tikzpicture}[scale = .75]
2069 \tkzGetNodes
2070 \tkzDrawCoordinates[smooth,red](PA.curve)
2071 \tkzDrawCoordinates[smooth,red](PA.curveb)
2072 \tkzDrawSegments[dashed](M,F M,G)
2073 \tkzDrawLine(F,G)
2074 \tkzDrawPoints[red](M)
2075 \tkzDrawPoints(C,F,G,K)
2076 \tkzLabelPoints(C,F,G,K)
2077 \end{tikzpicture}
2078 \end{center}
2079 \end{minipage}
2080
2081 \subsubsection{Function \tkzFct{math}{EL\_bifocal}}
2082 \label{ssub:_igfct_math_el__bifocal}
2083
2084 For the ellipse, two methods are available.
2085 The first one, \code{EL\_bifocal}, follows the same principle as for the hyperbola: it uses the bifocal definition of the ellipse.
2086
2087 This function takes as input the two foci and either the semi-major axis \( a \) or a point on the ellipse.
2088 The main attributes of the ellipse are then computed using the standard bifocal relationships.
2089
2090 \vspace{1em}
2091
2092
2093 \begin{verbatim}
2094 \directlua{
2095 init_elements()
2096 z.F = point(1, -1)
2097 z.G = point(4, 3)
2098 z.M = point(2, 4)
2099 z.C = tkz.midpoint(z.F, z.G)
2100 local a = (tkz.length(z.F, z.M) + tkz.length(z.G, z.M)) / 2
2101 CO.EL = conic(EL_bifocal(z.F, z.G, z.M))
2102 PA.curve = CO.EL:points(0, 1, 100)
2103 L.dir = CO.EL.directrix
2104 z.K = CO.EL.K
2105 z.Kp = z.C:symmetry(z.K)
2106 z.u, z.v = CO.EL.minor_axis:get()
2107 z.r, z.s = CO.EL.directrix:get()}
2108 \begin{tikzpicture}[scale = .5]
2109 \tkzGetNodes
2110 \tkzDrawCoordinates[smooth](PA.curve)
2111 \tkzDrawLines[add = .5 and .5](K,K' u,v r,s)
2112 \tkzDrawSegments[dashed](M,F M,G)
2113 \tkzDrawPoints(C,F,K,K',G,M)
2114 \tkzLabelPoints(C,F,K,K',G,M)
2115 \end{tikzpicture}
2116 \end{verbatim}
2117
2118
2119 \directlua{
2120 init_elements()
2121 z.F = point(1, -1)
2122 z.G = point(4, 3)
2123 z.M = point(2, 4)
2124 z.C = tkz.midpoint(z.F, z.G)
2125 local a = (tkz.length(z.F, z.M) + tkz.length(z.G, z.M)) / 2
2126 CO.EL = conic(EL_bifocal(z.F, z.G, z.M))
2127 PA.curve = CO.EL:points(0, 1, 100)
2128 L.dir = CO.EL.directrix
2129 z.K = CO.EL.K
2130 z.Kp = z.C:symmetry(z.K)
2131 z.u, z.v = CO.EL.minor_axis:get()
2132 z.r, z.s = CO.EL.directrix:get()}
2133 \begin{center}
2134 \begin{tikzpicture}[scale = .5]
2135 \tkzGetNodes
2136 \tkzDrawCoordinates[smooth](PA.curve)
2137 \tkzDrawLines[add = .5 and .5](K,K' u,v r,s)
2138 \tkzDrawSegments[dashed](M,F M,G)
2139 \tkzDrawPoints(C,F,K,K',G,M)
2140 \tkzLabelPoints(C,F,K,K',G,M)
2141 \end{tikzpicture}
2142 \end{center}
2143
2144 \subsubsection{Function \tkzFct{math}{EL\_points(pt, pt, pt)}}
2145 \label{ssub:_math_el__points}
2146
2147 The second method corresponds to the classical approach based on the center, a vertex, and a covertex of the ellipse.
2148 The function \code{EL\_points} takes these three points as arguments and computes all necessary attributes of the ellipse.
2149
2150 This approach replaces older constructions that manually derived parameters step by step—those lines have now been condensed into this single function.
2151
2152 \vspace{1em}
2153
2154 \begin{minipage}{.5\textwidth}
2155 \begin{verbatim}
2156 \directlua{
2157 init_elements()
2158 z.C = point(1, -1)
2159 z.V = point(4, 3)
2160 z.W = (z.C - z.V):orthogonal(3):at(z.C)
2161 local a = tkz.length(z.C, z.V)
2162 local b = tkz.length(z.C, z.W)
2163 local c = math.sqrt(a ^ 2 - b ^ 2)
2164 local e = c / a
2165 axis = line(z.C, z.V)
2166 % foci
2167 z.F = axis:report(c, z.C)
2168 z.G = z.C:symmetry(z.F)
2169 % directrix
2170 z.K = axis:report(b ^ 2 / c, z.F)
2171 z.Kp = axis:report(-b ^ 2 / c, z.G)
2172 % major_axis
2173 z.u = (z.C - z.K):orthogonal(2):at(z.K)
2174 z.v = (z.C - z.K):orthogonal(-2):at(z.K)
2175 L.dir = line(z.u, z.v)
2176 % axis:ortho_from (z.K)
2177 z.r = (z.C - z.Kp):orthogonal(2):at(z.Kp)
2178 z.s = (z.C - z.Kp):orthogonal(-2):at(z.Kp)
2179 % CO = conic(z.F,L.dir,e)
2180 CO.EL = conic(EL_points(z.C, z.V, z.W))
2181 PA.curve = CO.EL:points(0, 1, 100)}
2182 \begin{tikzpicture}[gridded]
2183 \tkzGetNodes
2184 \tkzDrawCoordinates[smooth](PA.curve)
2185 \tkzDrawLines(u,v r,s K,K')
2186 \tkzDrawLine(C,V)
2187 \tkzDrawPoints(V,W,C,F,K,K',G)
2188 \tkzLabelPoints(V,W,C,F,K,K',G)
2189 \end{tikzpicture}
2190 \end{verbatim}
2191 \end{minipage}
2192 \begin{minipage}{.5\textwidth}
2193 \directlua{
2194 init_elements()
2195 z.C = point(1, -1)
2196 z.V = point(4, 3)
2197 z.W = (z.C - z.V):orthogonal(3):at(z.C)
2198 local a = tkz.length(z.C, z.V)
2199 local b = tkz.length(z.C, z.W)
2200 local c = math.sqrt(a ^ 2 - b ^ 2)
2201 local e = c / a
2202 axis = line(z.C, z.V)
2203 % foci
2204 z.F = axis:report(c, z.C)
2205 z.G = z.C:symmetry(z.F)
2206 % directrix
2207 z.K = axis:report(b ^ 2 / c, z.F)
2208 z.Kp = axis:report(-b ^ 2 / c, z.G)
2209 % major_axis
2210 z.u = (z.C - z.K):orthogonal(2):at(z.K)
2211 z.v = (z.C - z.K):orthogonal(-2):at(z.K)
2212 L.dir = line(z.u, z.v)
2213 % axis : ortho_from(z.K)
2214 z.r = (z.C - z.Kp):orthogonal(2):at(z.Kp)
2215 z.s = (z.C - z.Kp):orthogonal(-2):at(z.Kp)
2216 % CO = conic(z.F,L.dir,e)
2217 CO.EL = conic(EL_points(z.C, z.V, z.W))
2218 PA.curve = CO.EL:points(0, 1, 100)}
2219 \begin{center}
2220 \begin{tikzpicture}[scale =.5]
2221 \tkzGetNodes
2222 \tkzDrawCoordinates[smooth](PA.curve)
2223 \tkzDrawLines(u,v r,s K,K')
2224 \tkzDrawLine(C,V)
2225 \tkzDrawPoints(V,W,C,F,K,K',G)
2226 \tkzLabelPoints(V,W,C,F,K,K',G)
2227 \end{tikzpicture}
2228 \end{center}
2229 \end{minipage}
2230
2231 \subsubsection{Function \tkzFct{conic}{EL\_radii(pt, ra, rb, slope)}}
2232 \label{ssub:function_radii}
2233
2234 This function defines an ellipse from its center (\code{pt}), its two radii (\( ra \) and \( rb \)), and the slope of its principal axis.
2235 Unlike the previous method, where the inclination was implicitly determined from the positions of the center and a vertex, here the slope must be explicitly provided as an argument.
2236
2237 This approach is useful when the ellipse is defined by its geometric parameters rather than specific points on the curve.
2238
2239 \vspace{1em}
2240
2241 \begin{tkzexample}[vbox]
2242 \directlua{
2243 z.A = point(0, 0)
2244 z.B = point(6, 0)
2245 z.C = point(1, 5)
2246 T.ABC = triangle(z.A, z.B, z.C)
2247 z.H = T.ABC.orthocenter
2248 z.O = T.ABC.circumcenter
2249 T.orthic = T.ABC:orthic()
2250 z.K = T.ABC:symmedian_point()
2251 z.Ha, z.Hb, z.Hc = T.orthic:get()
2252 z.a, z.b, z.c = T.ABC:tangential():get()
2253 z.p, z.q, z.r = T.ABC:circumcevian(z.H):get()
2254 z.Sa, z.Sb = z.K:symmetry(z.Ha,z.Hb)
2255 local coefficients = search_ellipse("Ha", "Hb", "Hc", "Sa", "Sb")
2256 local center, ra, rb, angle = ellipse_axes_angle(coefficients)
2257 CO.EL = conic(EL_radii(center, ra, rb, angle))
2258 % or CO.EL = conic(EL_radii(ellipse_axes_angle(coefficients)))
2259 PA.curve = CO.EL:points(0, 1, 100)}
2260
2261 \begin{center}
2262 \begin{tikzpicture}[gridded,scale =1.20]
2263 \tkzGetNodes
2264 \tkzDrawCoordinates[smooth,red](PA.curve)
2265 \tkzDrawPolygons[red](A,B,C)
2266 \tkzDrawPoints(A,B,C,K,Ha,Hb,Hc)
2267 \tkzDrawSegments[red](C,Hc B,Hb A,Ha)
2268 \tkzDrawPolygons[blue](Ha,Hb,Hc)
2269 \tkzLabelPoints(A,B)
2270 \tkzLabelPoints[above](C)
2271 \tkzLabelPoints[font=\small,left](Hb)
2272 \tkzLabelPoints[font=\small](Hc)
2273 \tkzLabelPoints[font=\small](Ha)
2274 \end{tikzpicture}
2275 \end{center}
2276 \end{tkzexample}
2277
2278 \subsubsection{Function \tkzFct{conic}{EL\_five\_points}(z1,z2,z3,z4,z5)}
2279
2280 \texttt{Arguments: }
2281
2282 Five points assumed to lie on the same ellipse.
2283
2284
2285 \medskip
2286 \texttt{Returns:} arguments suitable for |conic:new(...)|
2287 This helper function computes a valid argument list for the constructor
2288 \tkzname{conic:new(...)} from five points of an ellipse.
2289
2290 It does not create a conic object by itself. The function first determines
2291 the general quadratic equation passing through the five given points, then
2292 extracts the geometric data of the ellipse, and finally converts them into
2293 parameters compatible with the constructor.
2294
2295
2296 \medskip
2297
2298 \texttt{Remark: } the five points must define a non-degenerate real ellipse.
2299 If the associated conic is degenerate, or if it is not an ellipse, an error is produced.
2300
2301 \begin{tkzexample}[latex= .4\textwidth]
2302 \directlua{
2303 init_elements()
2304 z.A = point(4, 3)
2305 z.D = point(0.2, 2)
2306 z.C = point(0.4, 0)
2307 z.B = point(3, 1.5)
2308 z.E = point(2, 4)
2309 CO.EL = conic:new(EL_five_points(z.A,z.B,z.C,z.D,z.E))
2310 PA.curve = CO.EL:points(0,1,100)
2311 }
2312 \begin{center}
2313 \begin{tikzpicture}
2314 \tkzGetNodes
2315 \tkzDrawCoordinates[smooth,red,thick](PA.curve)
2316 \tkzDrawPoints(A,B,C,D,E)
2317 \tkzLabelPoints(A,B,C,D,E)
2318 \end{tikzpicture}
2319 \end{center}
2320 \end{tkzexample}
2321
2322
2323 \subsubsection{Function \tkzFct{conic}{search\_ellipse(s1, s2, s3, s4, s5)}}
2324 \label{ssub:search_ellipse}
2325
2326 This function, which will eventually be renamed \code{five\_points}, is currently limited to ellipses.
2327
2328 Given five points lying on an ellipse, it computes the coefficients of the general conic equation
2329 \[
2330 f(x, y) = Ax^2 + Bxy + Cy^2 + Dx + Ey + F,
2331 \]
2332 by solving a linear system using Gauss–Jordan elimination.
2333 The sixth coefficient \( F \) is fixed to \( 1 \), reducing the number of unknowns to five.
2334
2335 The arguments are the *names* of the points (as strings), not the points themselves. The method builds a linear system where each point satisfies the equation above, then solves it to find the values of \( A, B, C, D, E \).
2336
2337 The results are stored in a table, indexed by the point names. You can retrieve the coefficients manually, as shown in the example, but functions using this output can also directly access the table, making it easier to work with.
2338
2339 \vspace{1em}
2340
2341 \begin{tkzexample}[latex=.35\textwidth]
2342 \directlua{
2343 z.A = point(4, 3)
2344 z.D = point(0.2, 2)
2345 z.C = point(0.4, 0)
2346 z.B = point(3, 1.5)
2347 z.E = point(2, 4)
2348 local coefficients = search_ellipse("A", "B", "C", "D", "E")
2349 local A, B, C, D, E, F =
2350 coefficients.A, coefficients.B,
2351 coefficients.C, coefficients.D,
2352 coefficients.E, coefficients.F
2353
2354 tex.print(" A = "..A)
2355 tex.print('\\\\')
2356 tex.print("B = "..B)
2357 tex.print('\\\\')
2358 tex.print("C = "..C)
2359 tex.print('\\\\')
2360 tex.print("D = "..D)
2361 tex.print('\\\\')
2362 tex.print("E = "..E)
2363 tex.print('\\\\')
2364 tex.print("F = "..F)}
2365 \end{tkzexample}
2366
2367 \subsubsection{Function \tkzFct{conic}{ellipse\_axes\_angle(t)}}
2368 \label{ssub:function_ellipse_axes_angle}
2369
2370 This function complements the previous one.
2371 Once the general equation of the ellipse has been determined, it becomes necessary to extract key geometric characteristics—such as the center, the radii, and the inclination of the principal axis—in order to work with the \code{ellipse} object.
2372
2373 To retrieve these attributes, simply pass the table of coefficients (as returned by \code{search\_ellipse}) to this function.
2374 It will compute and return all the necessary parameters for further use.
2375
2376 \vspace{1em}
2377
2378 \begin{minipage}{.3\textwidth}
2379 \directlua{
2380 init_elements()
2381 z.A = point(3, 3)
2382 z.D = point(0.2, 2)
2383 z.C = point(0.4, 0)
2384 z.B = point(3, 1)
2385 z.E = point(2, 4)
2386 local coefficients = search_ellipse("A", "B", "C", "D", "E")
2387 local center,
2388 ra, rb, angle = ellipse_axes_angle(coefficients)
2389 z.W = center
2390 CO.EL = conic(EL_radii(center, ra, rb, angle))
2391 PA.curve = CO.EL:points(0, 1, 100)}
2392 \begin{tikzpicture}[gridded]
2393 \tkzGetNodes
2394 \tkzDrawCoordinates[smooth,red](PA.curve)
2395 \tkzDrawPolygons[red](A,B,C,D,E)
2396 \tkzDrawPoints(A,B,C,D,E,W)
2397 \tkzLabelPoints[left](C,D)
2398 \tkzLabelPoints[right](A,B)
2399 \tkzLabelPoints[above](E)
2400 \tkzLabelPoints(W)
2401 \end{tikzpicture}
2402 \end{minipage}
2403 \begin{minipage}{.7\textwidth}
2404 \begin{tkzexample}[code only]
2405 \directlua{
2406 init_elements()
2407 z.A = point(3, 3)
2408 z.D = point(0.2, 2)
2409 z.C = point(0.4, 0)
2410 z.B = point(3, 1)
2411 z.E = point(2, 4)
2412 local coefficients = search_ellipse("A", "B", "C", "D", "E")
2413 local center, ra, rb,
2414 angle = ellipse_axes_angle(coefficients)
2415 z.W = center
2416 CO.EL = conic(EL_radii(center, ra, rb, angle))
2417 PA.curve = CO.EL:points(0, 1, 100)}
2418 \end{tkzexample}
2419 \end{minipage}
2420
2421 \subsubsection{Function \tkzFct{conic}{test\_ellipse(pt, t)}}
2422 \label{ssub:function_test_ellipse}
2423
2424 This function checks whether a given point \code{pt} lies on the ellipse whose general equation is defined by the coefficients stored in table \code{t}.
2425
2426 It evaluates the equation
2427 \[
2428 f(x, y) = Ax^2 + Bxy + Cy^2 + Dx + Ey + F
2429 \]
2430 at the coordinates of the point, using the values from the table \code{t}.
2431
2432 This is particularly useful for verifying whether a point satisfies the equation of a previously computed ellipse.
2433 For example, the function can be used to test a point against the ellipse defined by the equation
2434 \[
2435 2x^2 + xy + y^2 - 5x - 2y + 1 = 0.
2436 \]
2437
2438 \vspace{1em}
2439
2440 \begin{minipage}{.4\textwidth}
2441 \directlua{
2442 init_elements()
2443 coefficients = {A = 2, B = 1, C = 1, D = -5, E = -2, F = 1}
2444 z.A = point(0, 1)
2445 if test_ellipse(z.A,coefficients)==0 then answer = "yes" end
2446 tex.print("A on the ellipse ?"..answer)
2447 local center, ra, rb,
2448 angle = ellipse_axes_angle(coefficients)
2449 z.W = center
2450 CO.EL = conic(EL_radii(center, ra, rb, angle))
2451 PA.curve = CO.EL:points(0, 1, 100)}
2452 \begin{tikzpicture}[gridded]
2453 \tkzGetNodes
2454 \tkzDrawCoordinates[smooth,red](PA.curve)
2455 \tkzDrawPoints(A,W)
2456 \tkzLabelPoints(A,W)
2457 \end{tikzpicture}
2458 \end{minipage}
2459 \begin{minipage}{.6\textwidth}
2460 \begin{tkzexample}[code only]
2461 \directlua{
2462 init_elements()
2463 coefficients = {A = 2, B = 1, C = 1, D = -5, E = -2, F = 1}
2464 z.A = point(0, 1)
2465 if test_ellipse(z.A,coefficients)==0 then
2466 answer = "yes" end
2467 tex.print("A on the ellipse ?"..answer)
2468 local center, ra, rb,
2469 angle = ellipse_axes_angle(coefficients)
2470 z.W = center
2471 CO.EL = conic(EL_radii(center, ra, rb, angle))
2472 PA.curve = CO.EL:points(0, 1, 100)}
2473 \end{tkzexample}
2474 \end{minipage}
2475
2476 \subsubsection{Function \tkzFct{conic}{search\_center\_ellipse(t)}}
2477 \label{ssub:function_search_center_ellipse}
2478
2479 This function computes the center of an ellipse from its general equation.
2480 The argument \code{t} is a table containing the coefficients \( A, B, C, D, E, F \) of the conic equation.
2481 The center is obtained by solving the system of equations corresponding to the partial derivatives \( \partial f / \partial x = 0 \) and \( \partial f / \partial y = 0 \).
2482
2483 \vspace{1em}
2484
2485
2486 \begin{minipage}{.3\textwidth}
2487 \directlua{
2488 coefficients = {A = .75, B = 1, C = 2, D = -5, E = -4, F = 4}
2489 local center = search_center_ellipse(coefficients)
2490 z.W = center
2491 local c, ra, rb,
2492 angle = ellipse_axes_angle(coefficients)
2493 CO.EL = conic(EL_radii(center, ra, rb, angle))
2494 PA.curve = CO.EL:points(0, 1, 100)}
2495 \begin{tikzpicture}[gridded,scale=.75]
2496 \tkzGetNodes
2497 \tkzDrawCoordinates[smooth,red](PA.curve)
2498 \tkzDrawPoints(W)
2499 \tkzLabelPoints(W)
2500 \end{tikzpicture}
2501 \end{minipage}
2502 \begin{minipage}{.7\textwidth}
2503 \begin{tkzexample}[code only]
2504 \directlua{
2505 coefficients = {A = .75, B = 1, C = 2, D = -5, E = -4, F = 4}
2506 local center = search_center_ellipse(coefficients)
2507 z.W = center
2508 local c, ra, rb,
2509 angle = ellipse_axes_angle(coefficients)
2510 CO.EL = conic(EL_radii(center, ra, rb, angle))
2511 cPA.urve = CO.EL:points(0, 1, 100)}
2512 \end{tkzexample}
2513 \end{minipage}
2514
2515
2516
2517 \subsubsection{Method \tkzMeth{conic}{asymptotes()}}
2518 \label{ssub:conic_asymptotes}
2519
2520 This method computes the asymptotes of a conic when the conic is a
2521 \emph{hyperbola}.
2522 For other types of conics (ellipse or parabola), asymptotes are not defined
2523 and an error is raised.
2524
2525 \medskip
2526
2527 \texttt{Description: }
2528 This method computes the asymptotes of a conic when the conic is a
2529 \emph{hyperbola}.
2530 For other types of conics (ellipse or parabola), asymptotes are not defined
2531 and an error is raised.
2532
2533 \medskip
2534
2535 Let $\mathcal{H}$ be a hyperbola with center $O$, semi-major axis $a$ and
2536 semi-minor axis $b$.
2537 The asymptotes of $\mathcal{H}$ are the two straight lines passing through the
2538 center $O$ and having slopes $\pm \tfrac{b}{a}$ with respect to the principal
2539 axis.
2540
2541 The method constructs these asymptotes geometrically:
2542 \begin{itemize}
2543 \item a point $P$ is computed on the transverse axis of the hyperbola,
2544 \item two directions orthogonal to the principal axis and scaled by $b$
2545 are constructed at $P$,
2546 \item the corresponding points are symmetrized with respect to the center
2547 in order to define two straight lines.
2548 \end{itemize}
2549
2550 \medskip
2551
2552 \texttt{Syntax:}
2553
2554 \begin{verbatim}
2555 L.a1, L.a2 = C:asymptotes()
2556 \end{verbatim}
2557
2558 \medskip
2559
2560 \texttt{Parameters: }
2561 None.
2562
2563 \medskip
2564
2565 \texttt{Return values: }
2566
2567 If the conic is an hyperbola, the method returns two objects of type
2568 \texttt{line}:
2569
2570 \begin{itemize}
2571 \item \texttt{L.a1}: first asymptote,
2572 \item \texttt{L.a2}: second asymptote.
2573 \end{itemize}
2574
2575 If the conic is not an hyperbola, an error is raised.
2576
2577 \medskip
2578
2579 \texttt{Example:}
2580
2581 \begin{tkzexample}[vbox]
2582 \directlua{
2583 init_elements()
2584 z.A = point(-2, -1)
2585 z.B = point(4, 0)
2586 L.AB = line(z.A, z.B)
2587 z.F = point(0, -3)
2588 CO.HY = conic(z.F, L.AB, 2)
2589 curve = CO.HY:points(-5, 5, 50)
2590 curveb = CO.HY:points(-5, 5, 50, swap)
2591 z.K = CO.HY.K
2592 z.S = CO.HY.vertex
2593 z.O = CO.HY.center
2594 z.X = CO.HY:point(1)
2595 L.A1, L.A2 = CO.HY:asymptotes()
2596 z.u1, z.v1 = L.A1:get()
2597 z.u2, z.v2 = L.A2:get()
2598 }
2599 \begin{tikzpicture}
2600 \tkzGetNodes
2601 \tkzDrawCoordinates[smooth,cyan](curve)
2602 \tkzDrawCoordinates[smooth,cyan](curveb)
2603 \tkzDrawPoint[mark=ball,ball color=red](X)
2604 \tkzDrawLines[purple](A,B F,K)
2605 \tkzDrawLines[red,thick,add=0 and 1](u1,v1 u2,v2)
2606 \tkzDrawPoints(A,B,F,K,S)
2607 \tkzLabelPoints(A,B,F,K,S)
2608 \end{tikzpicture}
2609 \end{tkzexample}
2610
2611 \medskip
2612
2613 \texttt{Remark: }
2614 The asymptotes are returned as infinite straight lines.
2615 They are independent of the chosen parametrization of the hyperbola and
2616 depend only on its geometric definition.
2617
2618 \endinput