summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-classes-ellipse.tex
blob: e700019fa3aac406854b2ea1b5d9806c02d119fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
\newpage
\section{Classe \Iclass{ellipse}} % (fold)
\label{sec:classe_ellipse}

\subsection{Attributes of an ellipse} % (fold)
\label{sub:attributes_of_an_ellipse}
The first attributes are the three points that define the ellipse : \Iattr{ellipse}{center} , \Iattr{ellipse}{vertex} and \Iattr{ellipse}{covertex}. The first method to define an ellipse is to give its center, then the point named \tkzname{vertex} which defines the major axis and finally the point named \tkzname{covertex} which defines the minor axis.


\bgroup
\catcode`_=12
\small
\captionof{table}{Ellipse attributes.}
\begin{tabular}{ll}
\toprule
\textbf{Attributes}     & \textbf{Application}\\
\Iattr{ellipse}{center} & center of the ellipse\\
\Iattr{ellipse}{vertex} & point of the major axis and of the ellipse\\
\Iattr{ellipse}{covertex} & point of the minor axis and of the ellipse\\
\Iattr{ellipse}{type}& The type is 'ellipse'\\
\Iattr{ellipse}{Rx}& Radius from center to vertex\\
\Iattr{ellipse}{Ry}& Radius from center to covertex\\
\Iattr{ellipse}{slope}& Slope of the line passes through the foci\\
\Iattr{ellipse}{Fa}& First focus\\
\Iattr{ellipse}{Fb}& Second focus\\
\Imeth{ellipse}{south} & See next example \ref{ssub:attributes_of_an_ellipse} \\
\Imeth{ellipse}{north} &   \\
\Imeth{ellipse}{west}  &   \\
\Imeth{ellipse}{east}  &   \\
\bottomrule %
\end{tabular}
\egroup


\subsubsection{Atributes of an ellipse: example} % (fold)
\label{ssub:attributes_of_an_ellipse}
\begin{tkzexample}[latex=0cm,small,code only]
\begin{tkzelements}
   z.C   = point: new (3 , 2)
   z.A   = point: new (5 , 1)
   L.CA  = line : new (z.C,z.A)
   z.b   = L.CA.north_pa
   L     = line : new (z.C,z.b)
   z.B   = L : point (0.5)
   E     = ellipse: new (z.C,z.A,z.B)
   a     = E.Rx
   b     = E.Ry
   z.F1  = E.Fa
   z.F2  = E.Fb
   slope = math.deg(E.slope)
   z.E   = E.east
   z.N   = E.north
   z.W   = E.west
   z.S   = E.south
   z.Co  = E.covertex
   z.Ve  = E.vertex
\end{tkzelements}
\begin{tikzpicture}
   \pgfkeys{/pgf/number format/.cd,fixed,precision=2}
   \tkzGetNodes
   \tkzDrawCircles[teal](C,A)
   \tkzDrawEllipse[red](C,\tkzUseLua{a},\tkzUseLua{b},
   \tkzUseLua{slope})
   \tkzDrawPoints(C,A,B,b,W,S,F1,F2)
   \tkzLabelPoints(C,A,B)
   \tkzDrawLine[add = .5 and .5](A,W)
   \tkzLabelSegment[pos=1.5,above,sloped](A,W){%
    slope = \pgfmathprintnumber{\tkzUseLua{slope}}}
   \tkzLabelPoint[below](S){South}
   \tkzLabelPoint[below left](F1){Focus 1}
   \tkzLabelPoint[below left](F2){Focus 2}
   \tkzLabelPoint[above right](Ve){Vertex ; East}
   \tkzLabelPoint[above right](Co){Covertex ; North}
\end{tikzpicture}
\end{tkzexample}

\begin{tkzelements}
z.C  = point: new (3 , 2)
z.A  = point: new (5 , 1)
L.CA = line : new (z.C,z.A)
z.b  = L.CA.north_pa
L    = line : new (z.C,z.b)
z.B  = L : point (0.5)
E    = ellipse: new (z.C,z.A,z.B)
a    = E.Rx
b    = E.Ry
z.F1 = E.Fa
z.F2 = E.Fb
slope    = math.deg(E.slope)
z.E  = E.east
z.N  = E.north
z.W  = E.west
z.S  = E.south
z.Co = E.covertex
z.Ve = E.vertex
\end{tkzelements}

\hspace*{\fill}
\begin{tikzpicture}
\pgfkeys{/pgf/number format/.cd,fixed,precision=2}
\tkzGetNodes
\tkzDrawCircles[teal](C,A)
\tkzDrawEllipse[red](C,\tkzUseLua{a},\tkzUseLua{b},\tkzUseLua{slope})
\tkzDrawPoints(C,A,B,b,W,S,F1,F2)
\tkzLabelPoints(C,A,B)
\tkzDrawLine[add = .5 and .5](A,W)
\tkzLabelSegment[pos=1.5,above,sloped](A,W){slope = \pgfmathprintnumber{\tkzUseLua{slope}}}
\tkzLabelPoint[below](S){South}
\tkzLabelPoint[below left](F1){Focus 1}
\tkzLabelPoint[below left](F2){Focus 2}
\tkzLabelPoint[above right](Ve){Vertex ; East}
\tkzLabelPoint[above right](Co){Covertex ; North}
\end{tikzpicture}
\hspace*{\fill}
% \caption{Class Ellipse}
% subsection attributes_of_an_ellipse (end)


\subsection{Methods of the class ellipse} % (fold)
\label{sub:methods_of_the_class_ellipse}
Before reviewing the methods and functions related to ellipses, let's take a look at how you can draw ellipses with \pkg{tkz-elements}. The \tkzcname{tkzDrawEllipse} macro requires 4 arguments: the center of the ellipse, the long radius (on the focus axis), the short radius and the angle formed by the focus axis.
The last three arguments must be transferred from \tkzNameEnv{tkzelements} to \tkzNameEnv{tikzpicture}.
To do this, you'll need to use a \pkg{tkz-elements }function: \Igfct{package}{set\_lua\_to\_tex}. See \ref{sec:math_functions} or the next examples. 

\vskip 1em
\lefthand\  You need to proceed with care, because unfortunately at the moment, the macros you create are global and you can overwrite existing macros. One solution is either to choose a macro name that won't cause any problems, or to save the initial macro.

\bgroup
\catcode`_=12 
\small
\captionof{table}{Ellipse methods.}
\begin{tabular}{ll}
\toprule
\textbf{Methods} & \textbf{Example}     \\
\midrule 
\Imeth{ellipse}{new (pc, pa ,pb)  }   &  E = ellipse: new ( center, vertex, covertex )   \\
\midrule
\Imeth{ellipse}{foci (f1,f2,v)} &  E = ellipse: foci ( focus 1, focus 2, vertex )    \\
\Imeth{ellipse}{radii (c,a,b,sl) }     &   E = ellipse: radii ( center, radius a, radius b, slope )  \\
\Imeth{ellipse}{in\_out (pt) }   & pt in/out of the ellipse  \\
\Imeth{ellipse}{tangent\_at (pt) }     &  see example \ref{ssub:method_point}   \\
\Imeth{ellipse}{tangent\_from (pt) }    &  see example \ref{ssub:method_point}    \\
\Imeth{ellipse}{point (t)  }   &  vertex = point (0) covertex = point (0.25) ex see  \ref{ssub:method_point}   \\
\bottomrule
\end{tabular}

\egroup

\subsubsection{Method \Imeth{ellipse}{new}} % (fold)
\label{ssub:method_imeth_ellipse_new}
The main method for creating a new ellipse is \Imeth{ellipse}{new}. The arguments are three: \Iattr{ellipse}{center}, \Iattr{ellipse}{vertex} and \Iattr{ellipse}{covertex}
For attributes see  \ref{sec:classe_ellipse}

\begin{minipage}{0.5\textwidth}
\begin{tkzexample}[latex=0cm,small,code only]
\begin{tkzelements}
   z.C      = point: new (3 , 2)
   z.A      = point: new (5 , 1)
   z.B      = z.C : homothety(0.5,
              z.C : rotation (math.pi/2,z.A))
   E        = ellipse: new (z.C,z.A,z.B)
   a        = E.Rx
   b        = E.Ry
   slope = math.deg(E.slope)
\end{tkzelements}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawCircles[teal](C,A)
   \tkzDrawEllipse[red](C,\tkzUseLua{a},
         \tkzUseLua{b},\tkzUseLua{slope})
   \tkzDrawPoints(C,A,B)
   \tkzLabelPoints(C,A,B)
\end{tikzpicture}
\end{tkzexample}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{tkzelements}
z.C    = point: new (3 , 2)
z.A    = point: new (5 , 1)
z.B    = z.C : homothety(0.5,
         z.C : rotation (math.pi/2,z.A))
E     = ellipse: new (z.C,z.A,z.B)
a     = E.Rx
b     = E.Ry
slope = math.deg(E.slope)
\end{tkzelements}
\begin{tikzpicture}
\tkzGetNodes
\tkzDrawCircles[teal](C,A)
\tkzDrawEllipse[red](C,\tkzUseLua{a},\tkzUseLua{b},\tkzUseLua{slope})
\tkzDrawPoints(C,A,B)
\tkzLabelPoints(C,A,B)
\end{tikzpicture}
\end{minipage}

The function \Igfct{package}{set\_lua\_to\_tex (list)} is used to define the macros that will be used to draw the ellipse with \TIKZ\ or \pkg{tkz-euclide}.
% subsubsection method_imeth_ellipse_new (end)


\subsubsection{Method \Imeth{ellipse}{foci}} % (fold)
\label{ssub:function_tkzname_ellipse__foci}
The first two points are the foci of the ellipse. The third one is the vertex. We can deduce all the other characteristics.

\emph{The function launches the |new| method, all the characteristics of the ellipse are defined.}

\begin{tkzexample}[latex=0cm,small,code only]
\begin{tkzelements}
   z.A      = point: new (0 , 0)
   z.B      = point: new (5 , 1)
   L.AB     = line : new (z.A,z.B)
   z.C      = point: new (.8 , 3)
   T.ABC    = triangle: new (z.A,z.B,z.C)
   z.N      = T.ABC.eulercenter
   z.H      = T.ABC.orthocenter
   z.O      = T.ABC.circumcenter
   _,_,z.Mc = get_points (T.ABC: medial ())
   L.euler  = line: new (z.H,z.O)
   C.circum = circle: new (z.O,z.A)
   C.euler  = circle: new (z.N,z.Mc)
   z.i,z.j  = intersection (L.euler,C.circum)
   z.I,z.J  = intersection (L.euler,C.euler)
   E        = ellipse: foci (z.H,z.O,z.I)
   L.AH     = line: new (z.A,z.H)
   z.X      = intersection (L.AH,C.circum)
   L.XO     = line: new (z.X,z.O)
   z.R,z.S  = intersection (L.XO,E)
   a,b      = E.Rx,E.Ry
   ang      = math.deg(E.slope)
\end{tkzelements}
\end{tkzexample}
\begin{minipage}{0.6\textwidth}
 \begin{tkzexample}[latex=0cm,small,code only]
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawPolygon(A,B,C)
   \tkzDrawCircles[cyan](O,A N,I)
   \tkzDrawSegments(X,R A,X)
   \tkzDrawEllipse[red](N,\tkzUseLua{a},
      \tkzUseLua{b},\tkzUseLua{ang})
   \tkzDrawLines[add=.2 and .5](I,H)
   \tkzDrawPoints(A,B,C,N,O,X,H,R,S,I)
   \tkzLabelPoints[above](C,X)
   \tkzLabelPoints[above right](N,O)
   \tkzLabelPoints[above left](R)
   \tkzLabelPoints[left](A)
   \tkzLabelPoints[right](B,I,S,H)
   \end{tikzpicture}
\end{tkzexample}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\begin{tkzelements}
   scale =1
   z.A   = point: new (0 , 0)
   z.B   = point: new (5 , 1)
   L.AB  = line : new (z.A,z.B)
   z.C   = point: new (.8 , 3)
   T.ABC     = triangle: new (z.A,z.B,z.C)
   z.N = T.ABC.eulercenter
   z.H = T.ABC.orthocenter
   z.O = T.ABC.circumcenter
   _,_,z.Mc  = get_points (T.ABC: medial ())
   L.euler   = line: new (z.H,z.O)
   C.circum  = circle: new (z.O,z.A)
   C.euler   = circle: new (z.N,z.Mc)
   z.i,z.j   = intersection (L.euler,C.circum)
   z.I,z.J   = intersection (L.euler,C.euler)
   E     = ellipse: foci (z.H,z.O,z.I)
   L.AH  = line: new (z.A,z.H)
   z.X   = intersection (L.AH,C.circum)
   L.XO  = line: new (z.X,z.O)
   z.R,z.S   = intersection (L.XO,E)
   a,b   = E.Rx,E.Ry
   ang   = math.deg(E.slope)
\end{tkzelements}
\begin{tikzpicture}
\tkzGetNodes
\tkzDrawPolygon(A,B,C)
\tkzDrawCircles[cyan](O,A N,I)
\tkzDrawSegments(X,R A,X)
\tkzDrawEllipse[red](N,\tkzUseLua{a},\tkzUseLua{b},\tkzUseLua{ang})
\tkzDrawLines[add=.2 and .5](I,H)
\tkzDrawPoints(A,B,C,N,O,X,H,R,S,I)
\tkzLabelPoints[above](C,X)
\tkzLabelPoints[above right](N,O)
\tkzLabelPoints[above left](R)
\tkzLabelPoints[left](A)
\tkzLabelPoints[right](B,I,S,H)
\end{tikzpicture}
\end{minipage}
% subsubsection function_tkzname_ellipse__foci (end)

\subsubsection{Method \Imeth{ellipse}{point} and \Imeth{ellipse}{radii}} % (fold)
\label{ssub:method_point}
 The method \Imeth{ellipse}{point} defines a point $M$ of the ellipse whose coordinates are $(a\times  cos(phi), b\times sin(phi))$. |phi| angle between (center,vertex) and (center,M)

 \emph{The environment \tkzNameEnv{tkzelements} uses as \tkzname{lua} the radian as unit for angles. }


\begin{minipage}{0.6\textwidth}
\begin{tkzexample}[latex=0cm,small,code only]
\begin{tkzelements}
   z.C         = point: new (2 , 3)
   z.A         = point: new (6 , 5)
   a           = value(4)
   b           = value(3)
   ang         = math.deg(-math.pi/4)
   E           = ellipse: radii (z.C,a,b,-math.pi/4)
   z.V         = E : point (0)
   z.K         = E : point (1)
   z.CoV       = E : point (0.25)
   z.X         = E : point (0.5)
   L           = E :tangent_at (z.V)
   z.x,z.y     = get_points(L)
   L.ta,L.tb   = E :tangent_from (z.A)
   z.M         = L.ta.pb
   z.N         = L.tb.pb
   L.K         = E :tangent_at (z.K)
   z.ka,z.kb   = get_points(L.K)
\end{tkzelements}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawSegments(C,V C,CoV)
   \tkzDrawLines(x,y A,M A,N ka,kb)
   \tkzLabelSegment(C,V){$a$}
   \tkzLabelSegment[right](C,CoV){$b$}
   \tkzDrawEllipse[teal](C,\tkzUseLua{a},\tkzUseLua{b},\tkzUseLua{ang})
   \tkzDrawPoints(C,V,CoV,X,x,y,M,N,A,K)
   \tkzLabelPoints(C,V,A,M,N,K)
   \tkzLabelPoints[above left](CoV)
\end{tikzpicture}
\end{tkzexample}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\begin{tkzelements}
scale       = .75
z.C         = point: new (2 , 3)
z.A         = point: new (6 , 5)
a           = value(4)
b           = value(3)
ang         = math.deg(-math.pi/4)
E           = ellipse: radii (z.C,a,b,-math.pi/4)
z.V         = E : point (0)
z.K         = E : point (1)
z.CoV       = E : point (0.25)
z.X         = E : point (0.5)
L           = E :tangent_at (z.V)
z.x,z.y     = get_points(L)
L.ta,L.tb   = E :tangent_from (z.A)
z.M         = L.ta.pb
z.N         = L.tb.pb
L.K         = E :tangent_at (z.K)
z.ka,z.kb   = get_points(L.K)
\end{tkzelements}
\begin{tikzpicture}
\tkzGetNodes
\tkzDrawSegments(C,V C,CoV)
\tkzDrawLines(x,y A,M A,N ka,kb)
\tkzLabelSegment(C,V){$a$}
\tkzLabelSegment[right](C,CoV){$b$}
\tkzDrawEllipse[teal](C,\tkzUseLua{a},\tkzUseLua{b},\tkzUseLua{ang})
\tkzDrawPoints(C,V,CoV,X,x,y,M,N,A,K)
\tkzLabelPoints(C,V,A,M,N,K)
\tkzLabelPoints[above left](CoV)
\end{tikzpicture}
\end{minipage}
% subsubsection method_point (end)
% subsection methods_of_the_class_ellipse (end)

% section classe_ellipse (end)
\endinput