Debian Codegraph @

texmf-dist/doc/latex/tkz-euclide/TKZdoc-euclide-drawing.tex

raw
1 \section{Drawing}
2 \tkzname{\tkznameofpack} can draw 5 types of objects : point, line or line segment, circle, arc and sector.
3
4 %<---------------------------------------------------------------------------->
5 % POINT(S)
6 %<---------------------------------------------------------------------------->
7 \subsection{Draw a point or some points}
8 There are two possibilities : \tkzcname{tkzDrawPoint} for a single point or \tkzcname{tkzDrawPoints} for one or more points.
9
10 \subsubsection{Drawing points \tkzcname{tkzDrawPoint}} \hypertarget{tdrp}{}
11
12 \begin{NewMacroBox}{tkzDrawPoint}{\oarg{local options}\parg{name}}%
13 \begin{tabular}{lll}%
14 arguments & default & definition \\
15 \midrule
16 \TAline{name of point} {no default} {Only one point name is accepted}
17 \bottomrule
18 \end{tabular}
19
20 \medskip
21 The argument is required. The disc takes the color of the circle, but lighter. It is possible to change everything. The point is a node and therefore it is invariant if the drawing is modified by scaling.
22
23 \medskip
24 \begin{tabular}{lll}%
25 \toprule
26 options & default & definition \\
27 \midrule
28 \TOline{\TIKZ\ options}{}{all \TIKZ\ options are valid.}
29 \TOline{shape} {circle}{Possible \tkzname{cross} or \tkzname{cross out}}
30 \TOline{size} {6}{$6 \times$ \tkzcname{pgflinewidth}}
31 \TOline{color} {black}{the default color can be changed }
32 \bottomrule
33 \end{tabular}
34
35 \medskip
36 {We can create other forms such as \tkzname{cross}}
37 \end{NewMacroBox}
38
39 By default, \tkzname{point style } is defined like this :
40
41 \begin{tkzltxexample}[]
42 \tikzset{point style/.style = {%
43 draw = black,
44 inner sep = 0pt,
45 shape = circle,
46 minimum size = 3 pt,
47 fill = black
48 }
49 }
50 \end{tkzltxexample}
51
52 \subsubsection{Example of point drawings}
53 Note that \tkzname{scale} does not affect the shape of the dots. Which is normal. Most of the time, we are satisfied with a single point shape that we can define from the beginning, either with a macro or by modifying a configuration file.
54
55 \begin{tkzexample}[latex=5cm,small]
56 \begin{tikzpicture}[scale=.5]
57 \tkzDefPoint(1,3){A}
58 \tkzDefPoint(4,1){B}
59 \tkzDefPoint(0,0){O}
60 \tkzDrawPoint[color=red](A)
61 \tkzDrawPoint[fill=blue!20,draw=blue](B)
62 \tkzDrawPoint[shape=cross,size=8pt,color=teal](O)
63 \end{tikzpicture}
64 \end{tkzexample}
65
66 It is possible to draw several points at once but this macro is a little slower than the previous one. Moreover, we have to make do with the same options for all the points.
67 \newpage
68 \hypertarget{tdrps}{}
69 \begin{NewMacroBox}{tkzDrawPoints}{\oarg{local options}\parg{liste}}%
70 \begin{tabular}{lll}%
71 arguments & default & definition \\
72 \midrule
73 \TAline{points list}{no default}{example \tkzcname{tkzDrawPoints(A,B,C)}}
74 \bottomrule
75 \end{tabular}
76
77 \medskip
78 \begin{tabular}{lll}%
79 options & default & definition \\
80 \midrule
81 \TOline{shape} {circle}{Possible \tkzname{cross} or \tkzname{cross out}}
82 \TOline{size} {6}{$6 \times$ \tkzcname{pgflinewidth}}
83 \TOline{color} {black}{the default color can be changed }
84 \bottomrule
85 \end{tabular}
86
87 \medskip
88 \tkzHandBomb\ Beware of the final \code{s}, an oversight leads to cascading errors if you try to draw multiple points. The options are the same as for the previous macro.
89 \end{NewMacroBox}
90
91 \subsubsection{Example}
92
93 \begin{tkzexample}[latex=7cm,small]
94 \begin{tikzpicture}
95 \tkzDefPoints{1/3/A,4/1/B,0/0/C}
96 \tkzDrawPoints[size=3,color=red,fill=red!50](A,B,C)
97 \end{tikzpicture}
98 \end{tkzexample}
99 %<---------------------------------------------------------------------------->
100 % LINE(S)
101 %<---------------------------------------------------------------------------->
102 \section{Drawing the lines}
103 The following macros are simply used to draw, name lines.
104 \subsection{Draw a straight line}
105 To draw a normal straight line, just give a couple of points. You can use the \tkzname{add} option to extend the line (This option is due to \tkzimp{Mark Wibrow}, see the code below).
106
107 The style of a line is by default :
108
109 \begin{tkzltxexample}[]
110 \tikzset{line style/.style = {%
111 line width = 0.6pt,
112 color = black,
113 style = solid,
114 add = {.2} and {.2}%
115 }}
116 \end{tkzltxexample}
117 with
118
119 \begin{tkzltxexample}[]
120 \tikzset{%
121 add/.style args={#1 and #2}{
122 to path={%
123 ($(\tikztostart)!-#1!(\tikztotarget)$)--($(\tikztotarget)!-#2!(\tikztostart)$)%
124 \tikztonodes}}}
125 \end{tkzltxexample}
126
127 You can modify this style with \tkzcname{tkzSetUpLine} see \ref{tkzsetupline}
128
129 \newpage
130 \begin{NewMacroBox}{tkzDrawLine}{\oarg{local options}\parg{pt1,pt2} }%
131 The arguments are a list of two points or three points. It would be possible, as for a half line, to create a style with \tkzcname{add}.
132
133 \begin{tabular}{lll}%
134 \toprule
135 options & default & definition \\
136 \midrule
137 \TOline{\TIKZ\ options}{}{all \TIKZ\ options are valid.}
138 \TOline{add}{0.2 and 0.2}{add = $kl$ and $kr$, \dots}
139 \TOline{\dots}{\dots}{allows the segment to be extended to the left and right. }
140 \bottomrule
141 \end{tabular}
142
143 \tkzname{add} defines the length of the line passing through the points pt1 and pt2. Both numbers are percentages. The styles of \TIKZ\ are accessible for plots.
144 \end{NewMacroBox}
145
146 \subsubsection{Examples with \tkzname{add}}
147 \begin{tkzexample}[latex=5cm,small]
148 \begin{tikzpicture}
149 \tkzInit[xmin=-2,xmax=3,ymin=-2.25,ymax=2.25]
150 \tkzClip[space=.25]
151 \tkzDefPoint(0,0){A} \tkzDefPoint(2,0.5){B}
152 \tkzDefPoint(0,-1){C}\tkzDefPoint(2,-0.5){D}
153 \tkzDefPoint(0,1){E} \tkzDefPoint(2,1.5){F}
154 \tkzDefPoint(0,-2){G} \tkzDefPoint(2,-1.5){H}
155 \tkzDrawLine(A,B) \tkzDrawLine[add = 0 and .5](C,D)
156 \tkzDrawLine[add = 1 and 0](E,F)
157 \tkzDrawLine[add = 0 and 0](G,H)
158 \tkzDrawPoints(A,B,C,D,E,F,G,H)
159 \tkzLabelPoints(A,B,C,D,E,F,G,H)
160 \end{tikzpicture}
161 \end{tkzexample}
162
163 It is possible to draw several lines, but with the same options.
164 \begin{NewMacroBox}{tkzDrawLines}{\oarg{local options}\parg{pt1,pt2 pt3,pt4 ...}}%
165 Arguments are a list of pairs of points separated by spaces. The styles of \TIKZ\ are available for the draws.
166 \end{NewMacroBox}
167
168 \subsubsection{Example with \tkzcname{tkzDrawLines}}
169
170 \begin{tkzexample}[latex=8cm,small]
171 \begin{tikzpicture}
172 \tkzDefPoint(0,0){A}
173 \tkzDefPoint(2,0){B}
174 \tkzDefPoint(1,2){C}
175 \tkzDefPoint(3,2){D}
176 \tkzDrawLines(A,B C,D A,C B,D)
177 \tkzLabelPoints(A,B,C,D)
178 \end{tikzpicture}
179 \end{tkzexample}
180 %<---------------------------------------------------------------------------->
181 % SEGMENT(S)
182 %<---------------------------------------------------------------------------->
183 \section{Drawing a segment}
184 There is, of course, a macro to simply draw a segment.
185
186 \subsection{Draw a segment \tkzcname{tkzDrawSegment}}
187 \begin{NewMacroBox}{tkzDrawSegment}{\oarg{local options}\parg{pt1,pt2}}%
188 The arguments are a list of two points. The styles of \TIKZ\ are available for the drawings.
189
190 \medskip
191 \begin{tabular}{lll}%
192 argument & example & definition \\
193 \midrule
194 \TAline{(pt1,pt2)}{(A,B)}{draw the segment $[A,B]$}
195 \bottomrule
196 \end{tabular}
197
198 \medskip
199 \begin{tabular}{lll}%
200 options & example & definition \\
201 \midrule
202 \TOline{\TIKZ\ options}{}{all \TIKZ\ options are valid.}
203 \TOline{dim}{no default}{dim = \{label,dim,option\}, \dots}
204 \TOline{\dots}{\dots}{allows you to add dimensions to a figure.}
205 \bottomrule
206 \end{tabular}
207
208 This is of course equivalent to \tkzcname{draw (A)--(B);}. You can also use the option \tkzname{add}.
209 \end{NewMacroBox}
210
211 \subsubsection{Example with point references}
212
213 \begin{tkzexample}[latex=6cm,small]
214 \begin{tikzpicture}[scale=1.5]
215 \tkzDefPoint(0,0){A}
216 \tkzDefPoint(2,1){B}
217 \tkzDrawSegment[color=red,thin](A,B)
218 \tkzDrawPoints(A,B)
219 \tkzLabelPoints(A,B)
220 \end{tikzpicture}
221 \end{tkzexample}
222
223 \subsubsection{Example of extending an segment with option \tkzname{add}}
224
225 \begin{tkzexample}[latex=7cm,small]
226 \begin{tikzpicture}
227 \tkzDefPoints{0/0/A,6/0/B,0.8/4/C}
228 \tkzDefTriangleCenter[euler](A,B,C)
229 \tkzGetPoint{E}
230 \tkzDefCircle[euler](A,B,C)\tkzGetPoints{E}{e}
231 \tkzDrawCircle[red](E,e)
232 \tkzDrawLines[add=.5 and .5](A,B A,C B,C)
233 \tkzDrawPoints(A,B,C,E)
234 \tkzLabelPoints(A,B,C,E)
235 \end{tikzpicture}
236 \end{tkzexample}
237
238 \subsubsection{Adding dimensions with option \tkzname{dim} new code from Muzimuzhi Z}
239 This code comes from an answer to this question on tex.stackexchange.com
240 (change-color-and-style-of-dimension-lines-in-tkz-euclide ).
241 The code of \tkzname{dim} is based on options of TikZ, you must add the units.
242 You can use now two styles : |dim style| and |dim fence style|. You have several ways to use them.
243 I'll let you look at the examples to see what you can do with these styles.
244
245 \begin{verbatim}
246 \tikzset{dim style/.append style={dashed}} % append if you want to keep precedent style.
247 or
248 \begin{scope}[ dim style/.append style={orange},
249 dim fence style/.style={dashed}]
250 \end{verbatim}
251
252 \begin{tkzexample}[latex=7cm]
253 \begin{tikzpicture}[scale=.75]
254 \tkzDefPoints{0/3/A, 1/-3/B}
255 \tkzDrawPoints(A,B)
256 \tkzDrawSegment[dim={\(l_0\),1cm,right=2mm},
257 dim style/.append style={red,
258 dash pattern={on 2pt off 2pt}}](A,B)
259 \tkzDrawSegment[dim={\(l_1\),2cm,right=2mm},
260 dim style/.append style={blue}](A,B)
261 \begin{scope}[ dim style/.style={orange},
262 dim fence style/.style={dashed}]
263 \tkzDrawSegment[dim={\(l_2\),3cm,right=2mm}](A,B)
264 \tkzDrawSegment[dim={\(l_3\),-2cm,right=2mm}](A,B)
265 \end{scope}
266 \tkzLabelPoints[left](A,B)
267 \end{tikzpicture}
268 \end{tkzexample}
269
270 \subsubsection{Adding dimensions with option \tkzname{dim} partI}
271 \begin{tkzexample}[latex=7cm,small]
272 \begin{tikzpicture}[scale=2]
273 \pgfkeys{/pgf/number format/.cd,fixed,precision=2}
274 \tkzDefPoint(0,0){A}
275 \tkzDefPoint(3.07,0){B}
276 \tkzInterCC[R](A,2.37)(B,1.82)
277 \tkzGetPoints{C}{C'}
278 \tkzDefCircle[in](A,B,C) \tkzGetPoints{G}{g}
279 \tkzDrawCircle(G,g)
280 \tkzDrawPolygon(A,B,C)
281 \tkzDrawPoints(A,B,C)
282 \tkzCalcLength(A,B)\tkzGetLength{ABl}
283 \tkzCalcLength(B,C)\tkzGetLength{BCl}
284 \tkzCalcLength(A,C)\tkzGetLength{ACl}
285 \begin{scope}[dim style/.style={dashed,sloped,teal}]
286 \tkzDrawSegment[dim={\pgfmathprintnumber\BCl,6pt,%
287 text=red}](C,B)
288 \tkzDrawSegment[dim={\pgfmathprintnumber\ACl,%
289 6pt,}](A,C)
290 \tkzDrawSegment[dim={\pgfmathprintnumber\ABl,%
291 -6pt,}](A,B)
292 \end{scope}
293 \tkzLabelPoints(A,B) \tkzLabelPoints[above](C)
294 \end{tikzpicture}
295 \end{tkzexample}
296
297 \subsubsection{Adding dimensions with option \tkzname{dim} part II}
298 \begin{tkzexample}[latex=6cm,small]
299 \begin{tikzpicture}[scale=.5]
300 \tkzDefPoints{0/0/O,-2/0/A,2/0/B,
301 -2/4/C,2/4/D,2/-4/E,-2/-4/F}
302 \tkzDrawPolygon(C,...,F)
303 \tkzDrawSegments(A,B)
304 \tkzDrawPoints(A,...,F,O)
305 \tkzLabelPoints[below left](A,...,F,O)
306 \tkzDrawSegment[dim={ $\sqrt{5}$,2cm,}](C,E)
307 \tkzDrawSegment[dim={ $\frac{\sqrt{5}}{2}$,1cm,}](O,E)
308 \tkzDrawSegment[dim={ $2$,2cm,left=8pt}](F,C)
309 \tkzDrawSegment[dim={ $1$,1cm,left=8pt}](F,A)
310 \end{tikzpicture}
311 \end{tkzexample}
312
313 \subsection{Drawing segments \tkzcname{tkzDrawSegments}}
314 If the options are the same we can plot several segments with the same macro.
315
316 \begin{NewMacroBox}{tkzDrawSegments}{\oarg{local options}\parg{pt1,pt2 pt3,pt4 ...}}%
317 The arguments are a two-point couple list. The styles of \TIKZ\ are available for the plots.
318 \end{NewMacroBox}
319
320 \begin{tkzexample}[latex=6cm,small]
321 \begin{tikzpicture}
322 \tkzInit[xmin=-1,xmax=3,ymin=-1,ymax=2]
323 \tkzClip[space=1]
324 \tkzDefPoint(0,0){A}
325 \tkzDefPoint(2,1){B}
326 \tkzDefPoint(3,0){C}
327 \tkzDrawSegments(A,B B,C)
328 \tkzDrawPoints(A,B,C)
329 \tkzLabelPoints(A,C)
330 \tkzLabelPoints[above](B)
331 \end{tikzpicture}
332 \end{tkzexample}
333
334 \subsubsection{Place an arrow on segment}
335 \begin{tkzexample}[latex=6cm,small]
336 \begin{tikzpicture}
337 \tkzSetUpStyle[postaction=decorate,
338 decoration={markings,
339 mark=at position .5 with {\arrow[thick]{#1}}
340 }]{myarrow}
341 \tkzDefPoint(0,0){A}
342 \tkzDefPoint(4,-4){B}
343 \tkzDrawSegments[myarrow=stealth](A,B)
344 \tkzDrawPoints(A,B)
345 \end{tikzpicture}
346 \end{tkzexample}
347
348 \subsection{Drawing line segment of a triangle}
349
350 \subsubsection{How to draw \tkzname{Altitude} }
351 \begin{tkzexample}[latex=7cm,small]
352 \begin{tikzpicture}[rotate=-90]
353 \tkzDefPoint(0,1){A}
354 \tkzDefPoint(2,4){C}
355 \tkzDefPointWith[orthogonal normed,K=7](C,A)
356 \tkzGetPoint{B}
357 \tkzDefSpcTriangle[orthic,name=H](A,B,C){a,b,c}
358 \tkzDrawLine[dashed,color=magenta](C,Hc)
359 \tkzDrawSegment[green!60!black](A,C)
360 \tkzDrawSegment[green!60!black](C,B)
361 \tkzDrawSegment[green!60!black](B,A)
362 \tkzLabelPoint[left](A){$A$}
363 \tkzLabelPoint[right](B){$B$}
364 \tkzLabelPoint[above](C){$C$}
365 \tkzLabelPoint[left](Hc){$Hc$}
366 \tkzLabelSegment[auto](B,A){$c$}
367 \tkzLabelSegment[auto,swap](B,C){$a$}
368 \tkzLabelSegment[auto,swap](C,A){$b$}
369 \tkzMarkAngle[size=1,color=cyan,mark=|](C,B,A)
370 \tkzMarkAngle[size=1,color=cyan,mark=|](A,C,Hc)
371 \tkzMarkAngle[size=0.75,
372 color=orange,mark=||](Hc,C,B)
373 \tkzMarkAngle[size=0.75,
374 color=orange,mark=||](B,A,C)
375 \tkzMarkRightAngle(A,C,B)
376 \tkzMarkRightAngle(B,Hc,C)
377 \end{tikzpicture}
378 \end{tkzexample}
379
380 \subsection{Drawing a polygon}
381 \begin{NewMacroBox}{tkzDrawPolygon}{\oarg{local options}\parg{points list}}%
382 Just give a list of points and the macro plots the polygon using the \TIKZ\ options present. You can replace $(A,B,C,D,E)$ by $(A,...,E)$ and $(P_1,P_2,P_3,P_4,P_5)$ by $(P_1,P...,P_5)$
383
384 \begin{tabular}{lll}%
385 \toprule
386 arguments & example & explanation \\
387 \midrule
388 \TAline{\parg{pt1,pt2,pt3,...}}{|\BS tkzDrawPolygon[gray,dashed](A,B,C)|}{Drawing a triangle}
389 \end{tabular}
390
391 \medskip
392 \begin{tabular}{lll}%
393 \toprule
394 options & default & example \\
395 \midrule
396 \TOline{Options TikZ}{...}{|\BS tkzDrawPolygon[red,line width=2pt](A,B,C)|}
397 \end{tabular}
398 \end{NewMacroBox}
399
400 \subsubsection{\tkzcname{tkzDrawPolygon}}
401
402 \begin{tkzexample}[latex=7cm, small]
403 \begin{tikzpicture} [rotate=18,scale=1]
404 \tkzDefPoints{0/0/A,2.25/0.2/B,2.5/2.75/C,-0.75/2/D}
405 \tkzDrawPolygon(A,B,C,D)
406 \tkzDrawSegments[style=dashed](A,C B,D)
407 \end{tikzpicture}
408 \end{tkzexample}
409
410 \subsubsection{Option \tkzname{two angles}}
411 \begin{tkzexample}[latex=6 cm,small]
412 \begin{tikzpicture}
413 \tkzDefPoint(0,0){A}
414 \tkzDefPoint(6,0){B}
415 \tkzDefTriangle[two angles = 50 and 70](A,B) \tkzGetPoint{C}
416 \tkzDrawPolygon(A,B,C)
417 \tkzLabelAngle[pos=1.4](B,A,C){$50^\circ$}
418 \tkzLabelAngle[pos=0.8](C,B,A){$70^\circ$}
419 \end{tikzpicture}
420 \end{tkzexample}
421
422 \subsubsection{Style of line}
423 \begin{tkzexample}[latex=8 cm,small]
424 \begin{tikzpicture}[scale=.6]
425 \tkzSetUpLine[line width=5mm,color=teal]
426 \tkzDefPoint(0,0){O}
427 \foreach \i in {0,...,5}{%
428 \tkzDefPoint({30+60*\i}:4){p\i}}
429 \tkzDefMidPoint(p1,p3) \tkzGetPoint{m1}
430 \tkzDefMidPoint(p3,p5) \tkzGetPoint{m3}
431 \tkzDefMidPoint(p5,p1) \tkzGetPoint{m5}
432 \tkzDrawPolygon[line join=round](p1,p3,p5)
433 \tkzDrawPolygon[teal!80,
434 line join=round](p0,p2,p4)
435 \tkzDrawSegments(m1,p3 m3,p5 m5,p1)
436 \tkzDefCircle[R](O,4.8)\tkzGetPoint{o}
437 \tkzDrawCircle[teal](O,o)
438 \end{tikzpicture}
439 \end{tkzexample}
440
441 \subsection{Drawing a polygonal chain}
442 \begin{NewMacroBox}{tkzDrawPolySeg}{\oarg{local options}\parg{points list}}%
443 Just give a list of points and the macro plots the polygonal chain using the \TIKZ\ options present.
444
445 \begin{tabular}{lll}%
446 \toprule
447 arguments & example & explanation \\
448 \midrule
449 \TAline{\parg{pt1,pt2,pt3,...}}{|\BS tkzDrawPolySeg[gray,dashed](A,B,C)|}{Drawing a triangle}
450 \end{tabular}
451
452 \medskip
453 \begin{tabular}{lll}%
454 \toprule
455 options & default & example \\
456 \midrule
457 \TOline{Options TikZ}{...}{|\BS tkzDrawPolySeg[red,line width=2pt](A,B,C)|}
458 \end{tabular}
459 \end{NewMacroBox}
460
461 \subsubsection{Polygonal chain}
462
463 \begin{tkzexample}[latex=7cm, small]
464 \begin{tikzpicture}
465 \tkzDefPoints{0/0/A,6/0/B,3/4/C,2/2/D}
466 \tkzDrawPolySeg(A,...,D)
467 \tkzDrawPoints(A,...,D)
468 \end{tikzpicture}
469 \end{tkzexample}
470
471 \subsubsection{The idea is to inscribe two squares in a semi-circle.}
472 A Sangaku look! It is a question of proving that one can inscribe in a half-disc, two squares, and to determine the length of their respective sides according to the radius.
473
474 \begin{tkzexample}[latex=7 cm,small]
475 \begin{tikzpicture}[scale=.75]
476 \tkzDefPoints{0/0/A,8/0/B,4/0/I}
477 \tkzDefSquare(A,B) \tkzGetPoints{C}{D}
478 \tkzInterLC(I,C)(I,B) \tkzGetPoints{E'}{E}
479 \tkzInterLC(I,D)(I,B) \tkzGetPoints{F'}{F}
480 \tkzDefPointsBy[projection=onto A--B](E,F){H,G}
481 \tkzDefPointsBy[symmetry = center H](I){J}
482 \tkzDefSquare(H,J) \tkzGetPoints{K}{L}
483 \tkzDrawSector(I,B)(A)
484 \tkzDrawPolySeg(H,E,F,G)
485 \tkzDrawPolySeg(J,K,L)
486 \tkzDrawPoints(E,G,H,F,J,K,L)
487 \end{tikzpicture}
488 \end{tkzexample}
489
490 \subsubsection{Polygonal chain: index notation}
491
492 \begin{tkzexample}[latex=7cm, small]
493 \begin{tikzpicture}
494 \foreach \pt in {1,2,...,8} {%
495 \tkzDefPoint(\pt*20:3){P_\pt}}
496 \tkzDrawPolySeg(P_1,P_...,P_8)
497 \tkzDrawPoints(P_1,P_...,P_8)
498 \end{tikzpicture}
499 \end{tkzexample}
500 %<---------------------------------------------------------------------------->
501 % CIRCLE
502 %<---------------------------------------------------------------------------->
503 \section{Draw a circle with \tkzcname{tkzDrawCircle}}
504
505 \subsection{Draw one circle}
506 \begin{NewMacroBox}{tkzDrawCircle}{\oarg{local options}\parg{A,B}}%
507 \tkzHandBomb\ Attention you need only two points to define a radius. An additional option \tkzname{R} is available to give a measure directly.
508
509 \medskip
510 \begin{tabular}{lll}%
511 \toprule
512 arguments & example & explanation \\
513 \midrule
514 \TAline{\parg{pt1,pt2}}{\parg{A,B}} {A center through B}
515 \bottomrule
516 \end{tabular}
517
518 \medskip
519 Of course, you have to add all the styles of \TIKZ\ for the tracings...
520 \end{NewMacroBox}
521
522 \subsubsection{Circles and styles, draw a circle and color the disc}
523 We'll see that it's possible to colour in a disc while tracing the circle.
524
525 \begin{tkzexample}[latex=7cm,small]
526 \begin{tikzpicture}
527 \tkzDefPoint(0,0){O}
528 \tkzDefPoint(3,0){A}
529 % circle with center O and passing through A
530 \tkzDrawCircle(O,A)
531 % diameter circle $[OA]$
532 \tkzDefCircle[diameter](O,A) \tkzGetPoint{I}
533 \tkzDrawCircle[new,fill=orange!10,opacity=.5](I,A)
534 % circle with center O and radius = exp(1) cm
535 \edef\rayon{\fpeval{0.25*exp(1)}}
536 \tkzDefCircle[R](O,\rayon) \tkzGetPoint{o}
537 \tkzDrawCircle[color=orange](O,o)
538 \end{tikzpicture}
539 \end{tkzexample}
540
541 \subsection{Drawing circles}
542 \begin{NewMacroBox}{tkzDrawCircles}{\oarg{local options}\parg{A,B C,D \dots}}%
543 \tkzHandBomb\ Attention, the arguments are lists of two points. The circles that can be drawn are the same as in the previous macro. An additional option \tkzname{R} is available to give a measure directly.
544
545 \medskip
546 \begin{tabular}{lll}%
547 \toprule
548 arguments & example & explanation \\
549 \midrule
550 \TAline{\parg{pt1,pt2 pt3,pt4 ...}}{\parg{A,B C,D}} {List of two points}
551 \bottomrule
552 \end{tabular}
553
554 \medskip
555 \begin{tabular}{lll}%
556 \toprule
557 options & default & definition \\
558 \midrule
559 \TOline{through}{through}{circle with two points defining a radius}
560 \bottomrule
561 \end{tabular}
562
563 \medskip
564 You do not need to use the default option \tkzname{through}.
565 Of course, you have to add all the styles of \TIKZ\ for the tracings...
566 \end{NewMacroBox}
567
568 \subsubsection{Circles defined by a triangle.}
569
570 \begin{tkzexample}[latex=9cm,small]
571 \begin{tikzpicture}
572 \tkzDefPoints{0/0/A,2/0/B,3/2/C}
573 \tkzDrawPolygon(A,B,C)
574 \tkzDrawCircles(A,B B,C C,A)
575 \tkzDrawPoints(A,B,C)
576 \tkzLabelPoints(A,B,C)
577 \end{tikzpicture}
578 \end{tkzexample}
579
580 \subsubsection{Concentric circles.}
581
582 \begin{tkzexample}[latex=7cm,small]
583 \begin{tikzpicture}
584 \tkzDefPoints{0/0/A,1/0/a,2/0/b,3/0/c}
585 \tkzDrawCircles(A,a A,b A,c)
586 \tkzDrawPoint(A)
587 \tkzLabelPoints(A)
588 \end{tikzpicture}
589 \end{tkzexample}
590
591 \subsubsection{Exinscribed circles.}
592
593 \begin{tkzexample}[latex=8cm,small]
594 \begin{tikzpicture}[scale=1]
595 \tkzDefPoints{0/0/A,4/0/B,1/2.5/C}
596 \tkzDrawPolygon(A,B,C)
597 \tkzDefCircle[ex](B,C,A)
598 \tkzGetPoint{J_c} \tkzGetSecondPoint{T_c}
599 \tkzDrawCircle(J_c,T_c)
600 \tkzDrawLines[add=0 and 1](C,A C,B)
601 \tkzDrawSegment(J_c,T_c)
602 \tkzMarkRightAngle(J_c,T_c,B)
603 \tkzDrawPoints(A,B,C,J_c,T_c)
604 \end{tikzpicture}
605 \end{tkzexample}
606
607 \subsubsection{Cardioid}
608 Based on an idea by O. Reboux made with pst-eucl (Pstricks module) by D. Rodriguez.
609
610 Its name comes from the Greek \textit{kardia (heart)}, in reference to its shape, and was given to it by Johan Castillon (Wikipedia).
611
612 \begin{tkzexample}[latex=7cm,small]
613 \begin{tikzpicture}[scale=.5]
614 \tkzDefPoint(0,0){O}
615 \tkzDefPoint(2,0){A}
616 \foreach \ang in {5,10,...,360}{%
617 \tkzDefPoint(\ang:2){M}
618 \tkzDrawCircle(M,A)
619 }
620 \end{tikzpicture}
621 \end{tkzexample}
622
623 \newpage
624
625 \subsection{Drawing semicircle}
626 \begin{NewMacroBox}{tkzDrawSemiCircle}{\oarg{local options}\parg{O,A}}%
627
628 \medskip
629 \begin{tabular}{lll}%
630 \toprule
631 arguments & example & explanation \\
632 \midrule
633 \TAline{\parg{pt1,pt2}}{\parg{O,A}} {OA= radius}
634 \bottomrule
635 \end{tabular}
636
637 $O$ center $A$ extremity of the semicircle
638 \end{NewMacroBox}
639
640 \subsubsection{Use of \tkzcname{tkzDrawSemiCircle}}
641
642 \begin{tkzexample}[latex=7cm,small]
643 \begin{tikzpicture}
644 \tkzDefPoint(0,0){A} \tkzDefPoint(6,0){B}
645 \tkzDefMidPoint(A,B) \tkzGetPoint{O}
646 \tkzDrawSemiCircle[blue](O,B)
647 \tkzDrawSemiCircle[red](O,A)
648 \tkzDrawPoints(O,A,B)
649 \tkzLabelPoints[below right](O,A,B)
650 \end{tikzpicture}
651 \end{tkzexample}
652
653 \subsection{Drawing semicircles}
654
655 \begin{NewMacroBox}{tkzDrawSemiCircles}{\oarg{local options}\parg{A,B C,D \dots}}%
656
657 \medskip
658 \begin{tabular}{lll}%
659 \toprule
660 arguments & example & explanation \\
661 \midrule
662 \TAline{\parg{pt1,pt2 pt3,pt4 ...}}{\parg{A,B C,D}} {List of two points}
663 \bottomrule
664 \end{tabular}
665
666 \end{NewMacroBox}
667
668 \subsubsection{Use of \tkzcname{tkzDrawSemiCircles} : Golden arbelos}
669
670 \begin{tkzexample}[vbox,small]
671 \begin{tikzpicture}[scale=.75]
672 \tkzDefPoints{0/0/A,10/0/B}
673 \tkzDefGoldenRatio(A,B) \tkzGetPoint{C}
674 \tkzDefMidPoint(A,B) \tkzGetPoint{O_0}
675 \tkzDefMidPoint(A,C) \tkzGetPoint{O_1}
676 \tkzDefMidPoint(C,B) \tkzGetPoint{O_2}
677 \tkzLabelPoints(A,B,C)
678 \tkzDrawSegment(A,B)
679 \tkzDrawPoints(A,B,C)
680 \begin{scope}[local bounding box = graph]
681 \tkzDrawSemiCircles[color=black](O_0,B)
682 \end{scope}
683 \useasboundingbox (graph.south west) rectangle (graph.north east);
684 \tkzClipCircle[out](O_1,C)\tkzClipCircle[out](O_2,B)
685 \tkzDrawSemiCircles[draw=none,fill=teal!15](O_0,B)
686 \tkzDrawSemiCircles[color=black](O_1,C O_2,B)
687 \end{tikzpicture}
688 \end{tkzexample}
689
690 %<---------------------------------------------------------------------------->
691 % Ellipse
692 %<---------------------------------------------------------------------------->
693 \section{Draw an ellipse with \tkzcname{tkzDrawEllipse}}
694
695 \subsection{Draw an ellipse}
696 \begin{NewMacroBox}{tkzDrawEllipse}{\oarg{local options}\parg{C,a,b,An}}%
697
698
699 \medskip
700 \begin{tabular}{lll}%
701 \toprule
702 arguments & example & explanation \\
703 \midrule
704 \TAline{\parg{C,a,b,An}}{\parg{C,4,2,45}} {C center; 4 and 2 lengths of half-axis} \\
705 & & 45 slope of main axis \\
706 \bottomrule
707 \end{tabular}
708
709 \medskip
710 Of course, you have to add all the styles of \TIKZ\ for the tracings...
711 \end{NewMacroBox}
712
713 \subsubsection{Example of drawing an ellipse }
714 \begin{tkzexample}[latex=6cm,small]
715 \begin{tikzpicture}[scale=.75]
716 \tkzDefPoint(0,4){C}
717 \tkzDrawEllipse[blue](C,4,2,45)
718 \tkzLabelPoints(C)
719 \end{tikzpicture}
720 \end{tkzexample}
721
722 %<---------------------------------------------------------------------------->
723 % ARC
724 %<---------------------------------------------------------------------------->
725 \section{Drawing arcs}
726 \subsection{Macro: \tkzcname{tkzDrawArc} }
727 \begin{NewMacroBox}{tkzDrawArc}{\oarg{local options}\parg{O,\dots}\parg{\dots}}%
728 This macro traces the arc of center $O$. Depending on the options, the arguments differ. It is a question of determining a starting point and an end point. Either the starting point is given, which is the simplest, or the radius of the arc is given. In the latter case, it is necessary to have two angles. Either the angles can be given directly, or nodes associated with the center can be given to determine them. The angles are in degrees.
729
730 \medskip
731 \begin{tabular}{lll}%
732 \toprule
733 options & default & definition \\
734 \midrule
735 \TOline{towards}{towards}{$O$ is the center and the arc from $A$ to $(OB)$}
736 \TOline{rotate} {towards}{the arc starts from $A$ and the angle determines its length}
737 \TOline{R}{towards}{We give the radius and two angles}
738 \TOline{R with nodes}{towards}{We give the radius and two points}
739 \TOline{angles}{towards}{We give the radius and two points}
740 \TOline{delta}{0}{angle added on each side }
741 \TOline{reverse}{false}{inversion of the arc's path, interesting to inverse arrow}
742 \bottomrule
743 \end{tabular}
744
745 \medskip
746 Of course, you have to add all the styles of \TIKZ\ for the tracings...
747
748 \medskip
749
750 \begin{tabular}{lll}%
751 \toprule
752 options & arguments & example \\
753 \midrule
754 \TOline{towards}{\parg{pt,pt}\parg{pt}}{\tkzcname{tkzDrawArc[delta=10](O,A)(B)}}
755 \TOline{rotate} {\parg{pt,pt}\parg{an}}{\tkzcname{tkzDrawArc[rotate,color=red](O,A)(90)}}
756 \TOline{R}{\parg{pt,$r$}\parg{an,an}}{\tkzcname{tkzDrawArc[R](O,2)(30,90)}}
757 \TOline{R with nodes}{\parg{pt,$r$}\parg{pt,pt}}{\tkzcname{tkzDrawArc[R with nodes](O,2)(A,B)}}
758 \TOline{angles}{\parg{pt,pt}\parg{an,an}}{\tkzcname{tkzDrawArc[angles](O,A)(0,90)}}
759 \end{tabular}
760 \end{NewMacroBox}
761
762 Here are a few examples:
763
764 \subsubsection{Option \tkzname{towards}}
765 It's useless to put \tkzname{towards}. In this first example the arc starts from $A$ and goes to $B$. The arc going from $B$ to $A$ is different. The salient is obtained by going in the direct direction of the trigonometric circle.
766 \begin{tkzexample}[latex=6cm,small]
767 \begin{tikzpicture}[scale=.75]
768 \tkzDefPoint(0,0){O}
769 \tkzDefPoint(2,-1){A}
770 \tkzDefPointBy[rotation= center O angle 90](A)
771 \tkzGetPoint{B}
772 \tkzDrawArc[color=orange,<->](O,A)(B)
773 \tkzDrawArc(O,B)(A)
774 \tkzDrawLines[add = 0 and .5](O,A O,B)
775 \tkzDrawPoints(O,A,B)
776 \tkzLabelPoints[below](O,A,B)
777 \end{tikzpicture}
778 \end{tkzexample}
779
780 \subsubsection{Option \tkzname{towards}}
781 In this one, the arc starts from A but stops on the right (OB).
782
783 \begin{tkzexample}[latex=6cm,small]
784 \begin{tikzpicture}[scale=0.75]
785 \tkzDefPoint(0,0){O}
786 \tkzDefPoint(2,-1){A}
787 \tkzDefPoint(1,1){B}
788 \tkzDrawArc[color=blue,->](O,A)(B)
789 \tkzDrawArc[color=gray](O,B)(A)
790 \tkzDrawArc(O,B)(A)
791 \tkzDrawLines[add = 0 and .5](O,A O,B)
792 \tkzDrawPoints(O,A,B)
793 \tkzLabelPoints[below](O,A,B)
794 \end{tikzpicture}
795 \end{tkzexample}
796
797 \subsubsection{Option \tkzname{rotate}}
798 \begin{tkzexample}[latex=6cm,small]
799 \begin{tikzpicture}[scale=0.75]
800 \tkzDefPoint(0,0){O}
801 \tkzDefPoint(2,-2){A}
802 \tkzDefPoint(60:2){B}
803 \tkzDrawLines[add = 0 and .5](O,A O,B)
804 \tkzDrawArc[rotate,color=red](O,A)(180)
805 \tkzDrawPoints(O,A,B)
806 \tkzLabelPoints[below](O,A,B)
807 \end{tikzpicture}
808 \end{tkzexample}
809
810 \subsubsection{Option \tkzname{R}}
811 \begin{tkzexample}[latex=6cm,small]
812 \begin{tikzpicture}[scale=0.75]
813 \tkzDefPoints{0/0/O}
814 \tkzSetUpCompass[<->]
815 \tkzDrawArc[R,color=teal,double](O,3)(270,360)
816 \tkzDrawArc[R,color=orange,double](O,2)(0,270)
817 \tkzDrawPoint(O)
818 \tkzLabelPoint[below](O){$O$}
819 \end{tikzpicture}
820 \end{tkzexample}
821
822 \subsubsection{Option \tkzname{R with nodes}}
823 \begin{tkzexample}[latex=6cm,small]
824 \begin{tikzpicture}[scale=0.75]
825 \tkzDefPoint(0,0){O}
826 \tkzDefPoint(2,-1){A}
827 \tkzDefPoint(1,1){B}
828 \tkzCalcLength(B,A)\tkzGetLength{radius}
829 \tkzDrawArc[R with nodes](B,\radius)(A,O)
830 \end{tikzpicture}
831 \end{tkzexample}
832
833 \subsubsection{Option \tkzname{delta}}
834 This option allows a bit like \tkzcname{tkzCompass} to place an arc and overflow on either side. delta is a measure in degrees.
835
836 \begin{tkzexample}[latex=7cm,small]
837 \begin{tikzpicture}
838 \tkzDefPoint(0,0){A}
839 \tkzDefPoint(3,0){B}
840 \tkzDefPointBy[rotation= center A angle 60](B)
841 \tkzGetPoint{C}
842 \begin{scope}% style only local
843 \tkzDefPointBy[symmetry= center C](A)
844 \tkzGetPoint{D}
845 \tkzDrawSegments(A,B A,D)
846 \tkzDrawLine(B,D)
847 \tkzSetUpCompass[color=orange]
848 \tkzDrawArc[orange,delta=10](A,B)(C)
849 \tkzDrawArc[orange,delta=10](B,C)(A)
850 \tkzDrawArc[orange,delta=10](C,D)(D)
851 \end{scope}
852
853 \tkzDrawPoints(A,B,C,D)
854 \tkzLabelPoints[below right](A,B,C,D)
855 \tkzMarkRightAngle(D,B,A)
856 \end{tikzpicture}
857 \end{tkzexample}
858
859 \subsubsection{Option \tkzname{angles}: example 1}
860
861 \begin{tkzexample}[latex=6cm,small]
862 \begin{tikzpicture}[scale=.75]
863 \tkzDefPoint(0,0){A}
864 \tkzDefPoint(5,0){B}
865 \tkzDefPoint(2.5,0){O}
866 \tkzDefPointBy[rotation=center O angle 60](B)
867 \tkzGetPoint{D}
868 \tkzDefPointBy[symmetry=center D](O)
869 \tkzGetPoint{E}
870 \begin{scope}
871 \tkzDrawArc[angles](O,B)(0,180)
872 \tkzDrawArc[angles,](B,O)(100,180)
873 \tkzCompass[delta=20](D,E)
874 \tkzDrawLines(A,B O,E B,E)
875 \tkzDrawPoints(A,B,O,D,E)
876 \end{scope}
877 \tkzLabelPoints[below right](A,B,O,D,E)
878 \tkzMarkRightAngle(O,B,E)
879 \end{tikzpicture}
880 \end{tkzexample}
881
882 \subsubsection{Option \tkzname{angles}: example 2}
883
884 \begin{tkzexample}[latex=7cm,small]
885 \begin{tikzpicture}
886 \tkzDefPoint(0,0){O}
887 \tkzDefPoint(5,0){I}
888 \tkzDefPoint(0,5){J}
889 \tkzInterCC(O,I)(I,O)\tkzGetPoints{B}{C}
890 \tkzInterCC(O,I)(J,O)\tkzGetPoints{D}{A}
891 \tkzInterCC(I,O)(J,O)\tkzGetPoints{L}{K}
892 \tkzDrawArc[angles](O,I)(0,90)
893 \tkzDrawArc[angles,color=gray,
894 style=dashed](I,O)(90,180)
895 \tkzDrawArc[angles,color=gray,
896 style=dashed](J,O)(-90,0)
897 \tkzDrawPoints(A,B,K)
898 \foreach \point in {I,A,B,J,K}{%
899 \tkzDrawSegment(O,\point)}
900 \end{tikzpicture}
901 \end{tkzexample}
902
903 \subsubsection{Option \tkzname{reverse}: inversion of the arrow}
904
905 \begin{tkzexample}[latex=6cm,small]
906 \begin{tikzpicture}
907 \tkzDefPoints{0/0/O,3/0/U}
908 \tkzDefPoint(10:1){A}
909 \tkzDefPoint(90:1){B}
910 \tkzLabelPoints(A,B)
911 \tkzDrawArc[reverse,tkz arrow={Stealth}](O,A)(B)
912 \tkzDrawPoints(A,B,O)
913 \end{tikzpicture}
914 \end{tkzexample}
915 %<---------------------------------------------------------------------------->
916 % SECTOR
917 %<---------------------------------------------------------------------------->
918 \section{Drawing a sector or sectors}
919 \subsection{\tkzcname{tkzDrawSector}}
920 \tkzHandBomb\ Attention the arguments vary according to the options.
921 \begin{NewMacroBox}{tkzDrawSector}{\oarg{local options}\parg{O,\dots}\parg{\dots}}%
922 \begin{tabular}{SlSlSl}%
923 options & default & definition \\
924 \midrule
925 \TOline{towards}{towards}{$O$ is the center and the arc from $A$ to $(OB)$}
926 \TOline{rotate} {towards}{the arc starts from $A$ and the angle determines its length }
927 \TOline{R}{towards}{We give the radius and two angles}
928 \TOline{R with nodes}{towards}{We give the radius and two points}
929
930 \end{tabular}
931
932 \medskip
933 \emph{You have to add, of course, all the styles of \TIKZ\ for tracings...}
934
935 \begin{tabular}{lll}%
936
937 options & arguments & example \\
938 \midrule
939 \TOline{towards}{\parg{pt,pt}\parg{pt}}{\tkzcname{tkzDrawSector(O,A)(B)}}
940 \TOline{rotate} {\parg{pt,pt}\parg{an}}{\tkzcname{tkzDrawSector[rotate,color=red](O,A)(90)}}
941 \TOline{R}{\parg{pt,$r$}\parg{an,an}}{\tkzcname{tkzDrawSector[R,color=teal](O,2)(30,90)}}
942 \TOline{R with nodes}{\parg{pt,$r$}\parg{pt,pt}}{\tkzcname{tkzDrawSector[R with nodes](O,2)(A,B)}}
943 \end{tabular}
944 \end{NewMacroBox}
945
946 Here are a few examples:
947
948 \subsubsection{\tkzcname{tkzDrawSector} and \tkzname{towards}}
949 There's no need to put \tkzname{towards}. You can use \tkzname{fill} as an option.
950
951 \begin{tkzexample}[latex=7cm,small]
952 \begin{tikzpicture}
953 \tkzDefPoint(0,0){O}
954 \tkzDefPoint(-30:1){A}
955 \tkzDefPointBy[rotation = center O angle -60](A)
956 \tkzDrawSector[teal](O,A)(tkzPointResult)
957 \begin{scope}[shift={(-60:1)}]
958 \tkzDefPoint(0,0){O}
959 \tkzDefPoint(-30:1){A}
960 \tkzDefPointBy[rotation = center O angle -60](A)
961 \tkzDrawSector[red](O,tkzPointResult)(A)
962 \end{scope}
963 \end{tikzpicture}
964 \end{tkzexample}
965
966 \subsubsection{\tkzcname{tkzDrawSector} and \tkzname{rotate}}
967 \begin{tkzexample}[latex=7cm,small]
968 \begin{tikzpicture}[scale=2]
969 \tkzDefPoints{0/0/O,2/2/A,2/1/B}
970 \tkzDrawSector[rotate,orange](O,A)(20)
971 \tkzDrawSector[rotate,teal](O,B)(-20)
972 \end{tikzpicture}
973 \end{tkzexample}
974
975 \subsubsection{\tkzcname{tkzDrawSector} and \tkzname{R}}
976 \begin{tkzexample}[latex=7cm,small]
977 \begin{tikzpicture}[scale=1.25]
978 \tkzDefPoint(0,0){O}
979 \tkzDefPoint(2,-1){A}
980 \tkzDrawSector[R](O,1)(30,90)
981 \tkzDrawSector[R](O,1)(90,180)
982 \tkzDrawSector[R](O,1)(180,270)
983 \tkzDrawSector[R](O,1)(270,360)
984 \end{tikzpicture}
985 \end{tkzexample}
986
987 \subsubsection{\tkzcname{tkzDrawSector} and \tkzname{R with nodes}}
988 In this example I use the option \tkzname{fill} but \tkzcname{tkzFillSector} is possible.
989 \begin{tkzexample}[latex=7cm,small]
990 \begin{tikzpicture}[scale=1.25]
991 \tkzDefPoint(0,0){O}
992 \tkzDefPoint(4,-2){A}
993 \tkzDefPoint(4,1){B}
994 \tkzDefPoint(3,3){C}
995 \tkzDrawSector[R with nodes,%
996 fill=teal!20](O,1)(B,C)
997 \tkzDrawSector[R with nodes,%
998 fill=orange!20](O,1.25)(A,B)
999 \tkzDrawSegments(O,A O,B O,C)
1000 \tkzDrawPoints(O,A,B,C)
1001 \tkzLabelPoints(A,B,C)
1002 \tkzLabelPoints[left](O)
1003 \end{tikzpicture}
1004 \end{tkzexample}
1005
1006 \subsubsection{\tkzcname{tkzDrawSector} and \tkzname{R with nodes}}
1007 \begin{tkzexample}[latex=6cm,small]
1008 \begin{tikzpicture} [scale=.4]
1009 \tkzDefPoints{-1/-2/A,1/3/B}
1010 \tkzDefRegPolygon[side,sides=6](A,B)
1011 \tkzGetPoint{O}
1012 \tkzDrawPolygon[fill=black!10, draw=blue](P1,P...,P6)
1013 \tkzLabelRegPolygon[sep=1.05](O){A,...,F}
1014 \tkzDrawCircle[dashed](O,A)
1015 \tkzLabelSegment[above,sloped,
1016 midway](A,B){\(A B = 16m\)}
1017 \foreach \i [count=\xi from 1] in {2,...,6,1}
1018 {%
1019 \tkzDefMidPoint(P\xi,P\i)
1020 \path (O) to [pos=1.1] node {\xi} (tkzPointResult) ;
1021 }
1022 \tkzDefRandPointOn[segment = P3--P5]
1023 \tkzGetPoint{S}
1024 \tkzDrawSegments[thick,dashed,red](A,S S,B)
1025 \tkzDrawPoints(P1,P...,P6,S)
1026 \tkzLabelPoint[left,above](S){$S$}
1027 \tkzDrawSector[R with nodes,fill=red!20](S,2)(A,B)
1028 \tkzLabelAngle[pos=1.5](A,S,B){$\alpha$}
1029 \end{tikzpicture}
1030 \end{tkzexample}
1031
1032 \endinput