summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tkz/tkz-elements/doc/latex/TKZdoc-elements-intersection.tex
blob: f632238e45227e692bef0b29b5deb4571b33eaba (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
\newpage
\section{Intersections} % (fold)
\label{sec:intersections}

It's an essential tool. For the moment, the classes concerned are lines, circles and ellipses, with the following combinations: line-line; line-circle; circle-circle and line-ellipse. The argument is a pair of objects, in any order.
Results consist of one or two values, either points, boolean \tkzname{false} or underscore |_|. 

\subsection{Line-line} % (fold)
\label{sub:line_line}

The result is of the form: |point| or |false|.

\begin{minipage}{0.6\textwidth}
\begin{tkzexample}[small,code only]
\begin{tkzelements}
   z.A   = point : new (1,-1)
   z.B   = point : new (4,1)
   z.C   = point : new (2,1)
   z.D   = point : new (4,-2) 
    z.I  = point : new (0,0)
   L.AB  = line : new (z.A,z.B)
   L.CD  = line : new (z.C,z.D)
   x     = intersection (L.AB,L.CD)
   if x  == false then 
   tex.print('error')
   else 
   z.I   = x
   end
\end{tkzelements}

\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawSegments(A,B C,D)
   \tkzDrawPoints(A,B,C,D,I)
   \tkzLabelPoints(A,B,C,D,I)
\end{tikzpicture}
\end{tkzexample}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\begin{tkzelements}
z.A   = point : new (1,-1)
z.B   = point : new (4,1)
z.C   = point : new (2,1)
z.D   = point : new (4,-2) 
 z.I  = point : new (0,0)
L.AB  = line : new (z.A,z.B)
L.CD  = line : new (z.C,z.D)
x = intersection (L.AB,L.CD)
if x  == false then 
tex.print('error')
else 
z.I   = x
end
\end{tkzelements}

\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawSegments(A,B C,D)
   \tkzDrawPoints(A,B,C,D,I)
   \tkzLabelPoints(A,B,C,D,I)
\end{tikzpicture}
\end{minipage}

Other examples: \ref{ssub:altshiller}, \ref{ssub:lemoine}, \ref{sub:alternate}
% subsection line_line (end)

\newpage
\subsection{Line-circle} % (fold)
\label{sub:line_circle}
The result is of the form : |point,point| or |false,false|. If the line is tangent to the circle, then the two points are identical. You can ignore one of the points by using the underscore: |_,point| or |point,_|. When the intersection yields two solutions, the order of the points is determined by the argument of |(z.p - z.c)| with |c| center of the circle and |p| point of intersection. The first solution corresponds to the smallest argument (arguments are between 0 and $2\pi$).

\begin{minipage}{0.6\textwidth}
\begin{tkzexample}[small,code only]
\begin{tkzelements}
   z.A   = point : new (1,-1)
   z.B   = point : new (1,2)
   L.AB  = line : new (z.A,z.B)
   z.O   = point : new (2,1)
   z.D   = point : new (3,1)
   z.E   = point : new (3,2)
   L.AE  = line : new (z.A,z.E)
   C.OD  = circle : new (z.O,z.D)
   z.I,_ = intersection (L.AB,C.OD)
   _,z.K = intersection (C.OD,L.AE)
\end{tkzelements}

\begin{tikzpicture}
\tkzGetNodes
   \tkzDrawLines(A,B A,E)
   \tkzDrawCircle(O,D)
   \tkzDrawPoints(A,B,O,D,I,K)
   \tkzLabelPoints[left](A,B,O,D,I,K)
\end{tikzpicture}
\end{tkzexample}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\begin{tkzelements}
   scale = 2
z.A = point : new (1,-1)
z.B = point : new (1,2)
L.AB = line : new (z.A,z.B)
z.O = point : new (2,1)
z.D = point : new (3,1)
z.E = point : new (3,2)
L.AE = line : new (z.A,z.E)
C.OD = circle : new (z.O,z.D)
z.I,_ = intersection (L.AB,C.OD)
_,z.K = intersection (C.OD,L.AE)
\end{tkzelements}

\begin{tikzpicture}
\tkzGetNodes
\tkzDrawLines(A,B A,E)
\tkzDrawCircle(O,D)
\tkzDrawPoints(A,B,O,D,I,K)
\tkzLabelPoints[left](A,B,O,D,I,K)
\end{tikzpicture}
\end{minipage}

Other examples: \ref{ssub:altshiller}
% subsection line_circle (end)

\newpage
\subsection{Circle-circle} % (fold)
\label{sub:circle_circle}

The result is of the form : |point,point| or |false,false|. If the circles are  tangent, then the two points are identical. You can ignore one of the points by using the underscore: |_ , point| or |point , _|. As for the intersection of a line and a circle, consider the argument of |z.p-z.c|  with |c| center of the first circle and |p| point of intersection. The first solution corresponds to the smallest argument (arguments are between 0 and $2\pi$).

\begin{minipage}{0.5\textwidth}
\begin{tkzexample}[small,code only]
\begin{tkzelements}
   z.A      = point : new (1,1)
   z.B      = point : new (2,2)
   z.C      = point : new (3,3)
   z.D      = point : new (3,0)
   C.AB     = circle : new (z.A,z.B)
   C.CB     = circle : new (z.C,z.B)
   z.I,_    = intersection (C.AB,C.CB)
   C.DC     = circle : new (z.D,z.C)
   z.J,z.K  = intersection (C.DC,C.CB)
\end{tkzelements}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawCircles(A,B C,B D,C)
   \tkzDrawPoints(A,I,C,D,J,K)
   \tkzLabelPoints(A,I,C,D,J,K)
\end{tikzpicture}
\end{tkzexample}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{tkzelements}
z.A = point : new (1,1)
z.B = point : new (2,2)
z.C = point : new (3,3)
z.D = point : new (3,0)
C.AB = circle : new (z.A,z.B)
C.CB = circle : new (z.C,z.B)
z.I,_ = intersection (C.AB,C.CB)
C.DC = circle : new (z.D,z.C)
 z.J,z.K = intersection (C.DC,C.CB)
\end{tkzelements}

\begin{tikzpicture}
\tkzGetNodes
\tkzDrawCircles(A,B C,B D,C)
\tkzDrawPoints(A,I,C,D,J,K)
\tkzLabelPoints(A,I,C,D,J,K)
\end{tikzpicture}
\end{minipage}

Other examples: \ref{ssub:altshiller}, \ref{sub:the_figure_pappus_circle}
% subsection circle_circle (end)

\newpage
\subsection{Line-ellipse} % (fold)
\label{sub:line_ellipse}
The following example is complex, but it shows the possibilities of Lua.
The designation of intersection points is a little more complicated than the previous one, as the argument characterizing the major axis must be taken into account.  The principle is the same, but this argument must be subtracted. In concrete terms, you need to consider the slopes of the lines formed by the center of the ellipse and the points of intersection, and the slope of the major axis.

\begin{minipage}{0.5\textwidth}
\begin{tkzexample}[code only,small]
\begin{tkzelements}
   scale    = .5
   z.a      = point: new (5 , 2)
   z.b      = point: new (-4 , 0)
   z.m      = point: new (2 , 4)
   z.n      = point: new (4 , 4)
   L.ab     = line : new (z.a,z.b)
   L.mn     = line : new (z.m,z.n)
   z.c      = L.ab. mid
   z.e      = L.ab: point (-.2)
   E        = ellipse: foci (z.a,z.b,z.e)
   z.u,z.v  = intersection (E,L.mn)
  -- transfer to tex
   a        = E.Rx
   b        = E.Ry
   ang      = math.deg(E.slope)
\end{tkzelements}
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawLines[red](a,b u,v) % p,s p,t
   \tkzDrawPoints(a,b,c,e,u,v) %
   \tkzLabelPoints(a,b,c,u,v)
   \tkzDrawEllipse[teal](c,\tkzUseLua{a},\tkzUseLua{b},\tkzUseLua{ang})
   \tkzDrawSegments(c,u c,v)
   \tkzFillAngles[green!30,opacity=.4](e,c,v)
   \tkzFillAngles[green!80,opacity=.4](e,c,u)
\end{tikzpicture}
\end{tkzexample}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{tkzelements}
   scale =.5
   z.a   = point: new (5 , 2)
   z.b   = point: new (-4 , 0)
   z.m   = point: new (2 , 4)
   z.n   = point: new (4 , 4)
   L.ab      = line : new (z.a,z.b)
   L.mn      = line : new (z.m,z.n)
   z.c   = L.ab. mid
   z.e   = L.ab: point (-.2)
   E     = ellipse: foci (z.a,z.b,z.e)
   z.u,z.v   = intersection (E,L.mn)
  -- transfer to tex
   a     = E.Rx
   b     = E.Ry
   ang   = math.deg(E.slope)
\end{tkzelements}
\hspace*{\fill}   
\begin{tikzpicture}
   \tkzGetNodes
   \tkzDrawLines[red](a,b u,v) % p,s p,t
   \tkzDrawPoints(a,b,c,e,u,v) %
   \tkzLabelPoints(a,b,c,u,v)
   \tkzDrawEllipse[teal](c,\tkzUseLua{a},\tkzUseLua{b},\tkzUseLua{ang})
   \tkzFillAngles[green!30,opacity=.4](e,c,v)
   \tkzFillAngles[green!80,opacity=.4](e,c,u)
   \tkzDrawSegments(c,u c,v)
\end{tikzpicture}
\hspace*{\fill}
\end{minipage}

Other examples: \ref{ssub:function_tkzname_ellipse__foci}, \ref{sub:hexagram}
%\caption{Intersection line and ellipse}

% \begin{tkzexample}[code only,small]
% \begin{tkzelements}
%    scale    = .5
%    z.a      = point: new (5 , 2)
%    z.b      = point: new (-4 , 0)
%    z.m      = point: new (2 , -3)
%    z.n      = point: new (4 , -3)
%    L.ab     = line : new (z.a,z.b)
%    L.mn     = line : new (z.m,z.n)
%    z.c      = L.ab. mid
%    z.e      = L.ab: point (-.2)
%    E        = ellipse: foci (z.a,z.b,z.e)
%    z.u,z.v  = intersection (E,L.mn)
%   -- transfer to tex
%    a        = E.Rx
%    b        = E.Ry
%    ang      = math.deg(E.slope)
% \end{tkzelements}
%
% \begin{tikzpicture}
%    \tkzGetNodes
%    \tkzDrawLines[red](a,b u,v) % p,s p,t
%    \tkzDrawPoints(a,b,c,e,u,v) %
%    \tkzLabelPoints(a,b,c,u,v)
%    \tkzDrawEllipse[teal](c,\tkzUseLua{a},\tkzUseLua{b},\tkzUseLua{ang})
%    \tkzFillAngles[green!30,opacity=.4](e,c,v)
%    \tkzDrawSegments(c,u c,v)
%    \tkzFillAngles[green!30,opacity=.4,size=1.2](e,c,v)
%    \tkzFillAngles[green!80,opacity=.4](e,c,u)
% \end{tikzpicture}
% \end{tkzexample}
%
% \begin{tkzelements}
%    scale=.5
%    z.a   = point: new (5 , 2)
%    z.b   = point: new (-4 , 0)
%    z.m   = point: new (2 , -3)
%    z.n   = point: new (4 , -3)
%    L.ab      = line : new (z.a,z.b)
%    L.mn      = line : new (z.m,z.n)
%    z.c   = L.ab. mid
%    z.e   = L.ab: point (-.2)
%    E     = ellipse: foci (z.a,z.b,z.e)
%    z.u,z.v   = intersection (E,L.mn)
%   -- transfer to tex
%    a     = E.Rx
%    b     = E.Ry
%    ang   = math.deg(E.slope)
% \end{tkzelements}
%
%
% \hspace*{\fill}
%  \begin{tikzpicture}
%    \tkzGetNodes
%    \tkzDrawLines[red](a,b u,v) % p,s p,t
%    \tkzDrawPoints(a,b,c,e,u,v) %
%    \tkzLabelPoints(a,b,c,u,v)
%    \tkzDrawEllipse[teal](c,\tkzUseLua{a},\tkzUseLua{b},\tkzUseLua{ang})
%   \tkzFillAngles[green!30,opacity=.4](e,c,v)
%    \tkzDrawSegments(c,u c,v)
%    \tkzFillAngles[green!30,opacity=.4,size=1.2](e,c,v)
%    \tkzFillAngles[green!80,opacity=.4](e,c,u)
% \end{tikzpicture}
% \hspace*{\fill}
%\caption{Intersection line and ellipse}

% subsection line_ellipse (end)
% section intersections (end)