Debian Codegraph @

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

raw
1 \section{Definition of polygons}
2 \subsection{Defining the points of a square} \label{def_square}
3 We have seen the definitions of some triangles. Let us look at the definitions of some quadrilaterals and regular polygons.
4
5 \begin{NewMacroBox}{tkzDefSquare}{\parg{pt1,pt2}}%
6 The square is defined in the forward direction. From two points, two more points are obtained such that the four taken in order form a square. The square is defined in the forward direction. \\The results are in \tkzname{tkzFirstPointResult} and \tkzname{tkzSecondPointResult}.\\
7 We can rename them with \tkzcname{tkzGetPoints}.
8
9 \medskip
10 \begin{tabular}{lll}%
11 \toprule
12 Arguments & example & explanation \\
13 \midrule
14 \TAline{\parg{pt1,pt2}}{\tkzcname{tkzDefSquare}\parg{A,B}}{The square is defined in the direct direction.}
15 \end{tabular}
16 \end{NewMacroBox}
17
18 \subsubsection{Using \tkzcname{tkzDefSquare} with two points}
19 Note the inversion of the first two points and the result.
20
21 \begin{tkzexample}[latex=4cm,small]
22 \begin{tikzpicture}[scale=.5]
23 \tkzDefPoint(0,0){A} \tkzDefPoint(3,0){B}
24 \tkzDefSquare(A,B)
25 \tkzDrawPolygon[new](A,B,tkzFirstPointResult,%
26 tkzSecondPointResult)
27 \tkzDefSquare(B,A)
28 \tkzDrawPolygon(B,A,tkzFirstPointResult,%
29 tkzSecondPointResult)
30 \end{tikzpicture}
31 \end{tkzexample}
32
33 We may only need one point to draw an isosceles right-angled triangle so we use \\ \tkzcname{tkzGetFirstPoint} or \tkzcname{tkzGetSecondPoint}.
34
35 \subsubsection{Use of \tkzcname{tkzDefSquare} to obtain an isosceles right-angled triangle}
36 \begin{tkzexample}[latex=7cm,small]
37 \begin{tikzpicture}[scale=1]
38 \tkzDefPoint(0,0){A}
39 \tkzDefPoint(3,0){B}
40 \tkzDefSquare(A,B) \tkzGetFirstPoint{C}
41 \tkzDrawSegment(A,B)
42 \tkzDrawSegments[new](A,C B,C)
43 \tkzMarkRightAngles(A,B,C)
44 \tkzDrawPoints(A,B) \tkzDrawPoint[new](C)
45 \tkzLabelPoints(A,B)
46 \tkzLabelPoints[new,above](C)
47 \end{tikzpicture}
48 \end{tkzexample}
49
50 \subsubsection{Pythagorean Theorem and \tkzcname{tkzDefSquare} }
51 \begin{tkzexample}[latex=8cm,small]
52 \begin{tikzpicture}[scale=.5]
53 \tkzDefPoint(0,0){C}
54 \tkzDefPoint(4,0){A}
55 \tkzDefPoint(0,3){B}
56 \tkzDefSquare(B,A)\tkzGetPoints{E}{F}
57 \tkzDefSquare(A,C)\tkzGetPoints{G}{H}
58 \tkzDefSquare(C,B)\tkzGetPoints{I}{J}
59 \tkzDrawPolygon(A,B,C)
60 \tkzDrawPolygon(A,C,G,H)
61 \tkzDrawPolygon(C,B,I,J)
62 \tkzDrawPolygon(B,A,E,F)
63 \tkzLabelSegment(A,C){$a$}
64 \tkzLabelSegment[right](C,B){$b$}
65 \tkzLabelSegment[swap](A,B){$c$}
66 \end{tikzpicture}
67 \end{tkzexample}
68
69 \subsection{Defining the points of a rectangle}
70 .
71
72 \begin{NewMacroBox}{tkzDefRectangle}{\parg{pt1,pt2}}%
73 The rectangle is defined in the forward direction. From two points, two more points are obtained such that the four taken in order form a rectangle. The two points passed in arguments are the ends of a diagonal of the rectangle. The sides are parallel to the axes.\\
74 The results are in \tkzname{tkzFirstPointResult} and \tkzname{tkzSecondPointResult}.\\
75 We can rename them with \tkzcname{tkzGetPoints}.
76
77 \medskip
78 \begin{tabular}{lll}%
79 \toprule
80 Arguments & example & explanation \\
81 \midrule
82 \TAline{\parg{pt1,pt2}}{\tkzcname{tkzDefRectangle}\parg{A,B}}{The rectangle is defined in the direct direction.}
83 \end{tabular}
84 \end{NewMacroBox}
85
86 \subsubsection{Example of a rectangle definition}
87 \begin{tkzexample}[latex=7 cm,small]
88 \begin{tikzpicture}
89 \tkzDefPoints{0/0/A,5/2/C}
90 \tkzDefRectangle(A,C) \tkzGetPoints{B}{D}
91 \tkzDrawPolygon[fill=teal!15](A,...,D)
92 \end{tikzpicture}
93 \end{tkzexample}
94
95 \subsection{Definition of parallelogram}
96
97 Defining the points of a parallelogram. It is a matter of completing three points in order to obtain a parallelogram.
98 \begin{NewMacroBox}{tkzDefParallelogram}{\parg{pt1,pt2,pt3}}%
99 \begin{tabular}{lll}%
100 \toprule
101 arguments & default & definition \\
102 \midrule
103 \TAline{\parg{pt1,pt2,pt3}}{no default}{Three points are necessary}
104 \bottomrule
105 \end{tabular}
106 \end{NewMacroBox}
107
108 From three points, another point is obtained such that the four taken in order form a parallelogram.
109 \\ The result is in \tkzname{tkzPointResult}. \\
110 We can rename it with the name \tkzcname{tkzGetPoint}...
111
112
113 \subsubsection{Example of a parallelogram definition}
114
115 \begin{tkzexample}[latex=7 cm,small]
116 \begin{tikzpicture}[scale=1]
117 \tkzDefPoints{0/0/A,3/0/B,4/2/C}
118 \tkzDefParallelogram(A,B,C)
119 % or \tkzDefPointWith[colinear= at C](B,A)
120 \tkzGetPoint{D}
121 \tkzDrawPolygon(A,B,C,D)
122 \tkzLabelPoints(A,B)
123 \tkzLabelPoints[above right](C,D)
124 \tkzDrawPoints(A,...,D)
125 \end{tikzpicture}
126 \end{tkzexample}
127
128
129 \subsection{The golden rectangle}
130 \begin{NewMacroBox}{tkzDefGoldenRectangle}{\parg{point,point}}%
131 The macro determines a rectangle whose size ratio is the number $\Phi$.\\
132 The created points are in \tkzname{tkzFirstPointResult} and \tkzname{tkzSecondPointResult}. \\
133 They can be obtained with the macro \tkzcname{tkzGetPoints}. The following macro is used to draw the rectangle.
134
135 \begin{tabular}{lll}%
136 \toprule
137 arguments & example & explanation \\
138 \midrule
139 \TAline{\parg{pt1,pt2}}{\parg{A,B}}{If C and D are created then $AB/BC=\Phi$.}
140 \end{tabular}
141
142 \tkzcname{tkzDefGoldenRectangle} or \tkzcname{tkzDefGoldRectangle}
143 \end{NewMacroBox}
144
145
146 \subsubsection{Golden Rectangles}
147 \begin{tkzexample}[latex=6 cm,small]
148 \begin{tikzpicture}[scale=.6]
149 \tkzDefPoint(0,0){A} \tkzDefPoint(8,0){B}
150 \tkzDefGoldRectangle(A,B) \tkzGetPoints{C}{D}
151 \tkzDefGoldRectangle(B,C) \tkzGetPoints{E}{F}
152 \tkzDefGoldRectangle(C,E) \tkzGetPoints{G}{H}
153 \tkzDrawPolygon(A,B,C,D)
154 \tkzDrawSegments(E,F G,H)
155 \end{tikzpicture}
156 \end{tkzexample}
157
158 \subsubsection{Construction of the golden rectangle }
159 Without the previous macro here is how to get the golden rectangle.
160
161 \begin{tkzexample}[latex=8cm,small]
162 \begin{tikzpicture}[scale=.5]
163 \tkzDefPoint(0,0){A}
164 \tkzDefPoint(8,0){B}
165 \tkzDefMidPoint(A,B)
166 \tkzGetPoint{I}
167 \tkzDefSquare(A,B)\tkzGetPoints{C}{D}
168 \tkzInterLC(A,B)(I,C)\tkzGetPoints{G}{E}
169 \tkzDefPointWith[colinear= at C](E,B)
170 \tkzGetPoint{F}
171 \tkzDefPointBy[projection=onto D--C ](E)
172 \tkzGetPoint{H}
173 \tkzDrawArc[style=dashed](I,E)(D)
174 \tkzDrawPolygon(A,B,C,D)
175 \tkzDrawPoints(C,D,E,F,H)
176 \tkzLabelPoints(A,B,C,D,E,F,H)
177 \tkzLabelPoints[above](C,D,F,H)
178 \tkzDrawSegments[style=dashed,color=gray]%
179 (E,F C,F B,E F,H H,C E,H)
180 \end{tikzpicture}
181 \end{tkzexample}
182
183
184
185
186 \subsection{Regular polygon}
187 \begin{NewMacroBox}{tkzDefRegPolygon}{\oarg{local options}\parg{pt1,pt2}}%
188 From the number of sides, depending on the options, this macro determines a regular polygon according to its center or one side.
189
190 \begin{tabular}{lll}%
191 \toprule
192 arguments & example & explanation \\
193 \midrule
194 \TAline{\parg{pt1,pt2}}{\parg{O,A}}{with option \code{center}, $O$ is the center of the polygon.}
195 \TAline{\parg{pt1,pt2}}{\parg{A,B}}{with option \code{side}, $[AB]$ is a side.}
196 \end{tabular}
197
198 \medskip
199 \begin{tabular}{lll}%
200 \toprule
201 options & default & example \\
202 \midrule
203 \TOline{name}{P}{The vertices are named $P1$,$P2$,\dots}
204 \TOline{sides}{5}{number of sides.}
205 \TOline{center}{center}{The first point is the center.}
206 \TOline{side}{center}{The two points are vertices.}
207 \TOline{Options TikZ}{...}{}
208 \end{tabular}
209 \end{NewMacroBox}
210
211 \subsubsection{Option \tkzname{center}}
212 \begin{tkzexample}[latex=7cm, small]
213 \begin{tikzpicture}
214 \tkzDefPoints{0/0/P0,0/0/Q0,2/0/P1}
215 \tkzDefMidPoint(P0,P1) \tkzGetPoint{Q1}
216 \tkzDefRegPolygon[center,sides=7](P0,P1)
217 \tkzDefMidPoint(P1,P2) \tkzGetPoint{Q1}
218 \tkzDefRegPolygon[center,sides=7,name=Q](P0,Q1)
219 \tkzFillPolygon[teal!20](Q0,Q1,P2,Q2)
220 \tkzDrawPolygon(P1,P...,P7)
221 \foreach \j in {1,...,7} {%
222 \tkzDrawSegment[black](P0,Q\j)}
223 \end{tikzpicture}
224 \end{tkzexample}
225
226 \subsubsection{Option \tkzname{side}}
227 \begin{tkzexample}[latex=7cm, small]
228 \begin{tikzpicture}[scale=1]
229 \tkzDefPoints{-4/0/A, -1/0/B}
230 \tkzDefRegPolygon[side,sides=5,name=P](A,B)
231 \tkzDrawPolygon[thick](P1,P...,P5)
232 \end{tikzpicture}
233 \end{tkzexample}
234 \endinput