Debian Codegraph @

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

raw
1 \section{First step: fixed points}
2
3 The first step in a geometric construction is to define the fixed points from which the figure will be constructed.
4
5 The general idea is to avoid manipulating coordinates and to prefer to use the references of the points fixed in the first step or obtained using the tools provided by the package. Even if it's possible, I think it's a bad idea to work directly with coordinates. Preferable is to use named points.
6
7 \tkzname{\tkznameofpack} uses macros and vocabulary specific to geometric construction. It is of course possible to use the tools of \TIKZ\ but it seems more logical to me not to mix the different syntaxes.
8
9 A point in \tkzname{\tkznameofpack} is a particular \code{node} for \TIKZ. In the next section we will see how to define points using coordinates. The style of the points (color and shape) will not be discussed. You will find some indications in some examples; for more information you can read the following section \ref{custom}.
10
11
12 \section{Definition of a point : \tkzcname{tkzDefPoint} or \tkzcname{tkzDefPoints}}
13
14 Points can be specified in any of the following ways:
15 \begin{itemize}
16 \item Cartesian coordinates;
17 \item Polar coordinates;
18 \item Named points;
19 \item Relative points.
20 \end{itemize}
21
22
23 A point is defined if it has a name linked to a unique pair of decimal numbers.
24 Let $(x,y)$ or $(a:d)$ i.e. ($x$ abscissa, $y$ ordinate) or ($a$ angle: $d$ distance).
25 This is possible because the plan has been provided with an orthonormed Cartesian coordinate system. The working axes are (ortho)normed with unity equal to $1$~cm.
26
27 The Cartesian coordinate $(a,b)$ refers to the
28 point $a$ centimeters in the $x$-direction and $b$ centimeters in the
29 $y$-direction.
30
31 A point in polar coordinates requires an angle $\alpha$, in degrees,
32 and a distance $d$ from the origin with a dimensional
33 unit by default it's the \texttt{cm}.
34
35 The \tkzNameMacro{tkzDefPoint} macro is used to define a point by assigning coordinates to it. This macro is based on
36
37 \tkzNameMacro{coordinate}, a macro of \TIKZ. It can use \TIKZ-specific options such as \tkzname{shift}. If calculations are required then the \tkzNamePack{xfp} package is chosen. We can use Cartesian or polar coordinates.
38
39 \begin{minipage}[t]{0.48\textwidth}
40 Cartesian coordinates
41 \begin{tkzexample}[code only,small]
42 \begin{tikzpicture}[scale=1]
43 \tkzInit[xmax=5,ymax=5]
44 % necessary to limit
45 % the size of the axes
46 \tkzDrawX[>=latex]
47 \tkzDrawY[>=latex]
48 \tkzDefPoints{0/0/O,1/0/I,0/1/J}
49 \tkzDefPoint(3,4){A}
50 \tkzDrawPoints(O,A)
51 \tkzLabelPoint[above](A){$A_1(x_1,y_1)$}
52 \tkzShowPointCoord[xlabel=$x_1$,
53 ylabel=$y_1$](A)
54 \tkzLabelPoints(O,I)
55 \tkzLabelPoints[left](J)
56 \tkzDrawPoints[shape=cross](I,J)
57 \end{tikzpicture}
58 \end{tkzexample}%
59 \end{minipage}
60 \begin{minipage}[t]{0.45\textwidth}
61 Polar coordinates
62 \begin{tkzexample}[code only,small]
63 \begin{tikzpicture}[scale=1]
64 \tkzInit[xmax=5,ymax=5]
65 \tkzDrawX[>=latex]
66 \tkzDrawY[>=latex]
67 \tkzDefPoints{0/0/O,1/0/I,0/1/J}
68 \tkzDefPoint(40:4){P}
69 \tkzDrawSegment[dim={$d$,
70 16pt,above=6pt}](O,P)
71 \tkzDrawPoints(O,P)
72 \tkzMarkAngle[mark=none,->](I,O,P)
73 \tkzFillAngle[opacity=.5](I,O,P)
74 \tkzLabelAngle[pos=1.25](I,O,P){%
75 $\alpha$}
76 \tkzLabelPoint[right](P){$P(\alpha:d)$}
77 \tkzDrawPoints[shape=cross](I,J)
78 \tkzLabelPoints(O,I)
79 \tkzLabelPoints[left](J)
80 \end{tikzpicture}
81 \end{tkzexample}
82 \end{minipage}%
83
84 \begin{minipage}[b]{0.45\textwidth}
85 \begin{tikzpicture}[scale=1]
86 \tkzInit[xmax=5,ymax=5]
87 \tkzDrawX[>=latex]
88 \tkzDrawY[>=latex]
89 \tkzDefPoints{0/0/O,1/0/I,0/1/J}
90 \tkzDefPoint(3,4){A}
91 \tkzDrawPoints(O,A)
92 \tkzLabelPoint[above](A){$A_1 (x_1,y_1)$}
93 \tkzShowPointCoord[xlabel=$x_1$,ylabel=$y_1$](A)
94 \tkzLabelPoints(O,I)
95 \tkzLabelPoints[left](J)
96 \tkzDrawPoints[shape=cross](I,J)
97 \end{tikzpicture}
98 \end{minipage}
99 \begin{minipage}[b]{0.45\textwidth}
100 \begin{tikzpicture}[,scale=1]
101 \tkzInit[xmax=5,ymax=5]
102 \tkzDrawX[>=latex]
103 \tkzDrawY[>=latex]
104 \tkzDefPoints{0/0/O,1/0/I,0/1/J}
105 \tkzDefPoint(40:4){P}
106 \tkzDrawSegment[dim={$d$,
107 16pt,above=6pt}](O,P)
108 \tkzDrawPoints(O,P)
109 \tkzMarkAngle[mark=none,->](I,O,P)
110 \tkzFillAngle[opacity=.5](I,O,P)
111 \tkzLabelAngle[pos=1.25](I,O,P){$\alpha$}
112 \tkzLabelPoint[right](P){$P (\alpha : d )$}
113 \tkzDrawPoints[shape=cross](I,J)
114 \tkzLabelPoints(O,I)
115 \tkzLabelPoints[left](J)
116 \end{tikzpicture}
117 \end{minipage}%
118
119 \subsection{Defining a named point \tkzcname{tkzDefPoint}}
120
121 \begin{NewMacroBox}{tkzDefPoint}{\oarg{local options}\parg{$x,y$}\marg{ref} or \parg{$\alpha$:$d$}\marg{ref}}%
122 \begin{tabular}{lll}%
123 arguments & default & definition \\
124 \midrule
125 \TAline{($x,y$)}{no default}{$x$ and $y$ are two dimensions, by default in cm.}
126 \TAline{($\alpha$:$d$)}{no default}{$\alpha$ is an angle in degrees, $d$ is a dimension}
127 \TAline{\{ref\}}{no default}{Reference assigned to the point: $A$, $T\_a$ ,$P1$ or $P_1$}
128 \bottomrule
129 \end{tabular}
130
131 \medskip
132 \emph{The obligatory arguments of this macro are two dimensions expressed with decimals, in the first case they are two measures of length, in the second case they are a measure of length and the measure of an angle in degrees. Do not confuse the reference with the name of a point. The reference is used by calculations, but frequently, the name is identical to the reference.}
133
134 \medskip
135 \begin{tabular}{lll}%
136 \toprule
137 options & default & definition \\
138 \midrule
139 \TOline{label} {no default} {allows you to place a label at a predefined distance}
140 \TOline{shift} {no default} {adds $(x,y)$ or $(\alpha:d)$ to all coordinates}
141 \end{tabular}
142 \end{NewMacroBox}
143
144 \subsubsection{Cartesian coordinates }
145
146 \begin{tkzexample}[latex=6cm,small]
147 \begin{tikzpicture}
148 \tkzInit[xmax=5,ymax=5] % limits the size of the axes
149 \tkzDrawX[>=latex]
150 \tkzDrawY[>=latex]
151 \tkzDefPoint(0,0){A}
152 \tkzDefPoint(4,0){B}
153 \tkzDefPoint(0,3){C}
154 \tkzDrawPolygon(A,B,C)
155 \tkzDrawPoints(A,B,C)
156 \end{tikzpicture}
157 \end{tkzexample}
158
159 \subsubsection{Calculations with \tkzNamePack{xfp}}
160
161 \begin{tkzexample}[latex=7cm,small]
162 \begin{tikzpicture}[scale=1]
163 \tkzInit[xmax=4,ymax=4]
164 \tkzDrawX\tkzDrawY
165 \tkzDefPoint(-1+2,sqrt(4)){O}
166 \tkzDefPoint({3*ln(exp(1))},{exp(1)}){A}
167 \tkzDefPoint({4*sin(pi/6)},{4*cos(pi/6)}){B}
168 \tkzDrawPoints(O,B,A)
169 \end{tikzpicture}
170 \end{tkzexample}
171
172 \subsubsection{Polar coordinates }
173
174 \begin{tkzexample}[latex=7cm,small]
175 \begin{tikzpicture}
176 \foreach \an [count=\i] in {0,60,...,300}
177 { \tkzDefPoint(\an:3){A_\i}}
178 \tkzDrawPolygon(A_1,A_...,A_6)
179 \tkzDrawPoints(A_1,A_...,A_6)
180 \end{tikzpicture}
181 \end{tkzexample}
182
183 \subsubsection{Relative points}
184 First, we can use the \tkzNameEnv{scope} environment from \TIKZ.
185 In the following example, we have a way to define an equilateral triangle.
186
187 \begin{tkzexample}[latex=7cm,small]
188 \begin{tikzpicture}[scale=1]
189 \begin{scope}[rotate=30]
190 \tkzDefPoint(2,3){A}
191 \begin{scope}[shift=(A)]
192 \tkzDefPoint(90:5){B}
193 \tkzDefPoint(30:5){C}
194 \end{scope}
195 \end{scope}
196 \tkzDrawPolygon(A,B,C)
197 \tkzLabelPoints[above](B,C)
198 \tkzLabelPoints[below](A)
199 \tkzDrawPoints(A,B,C)
200 \end{tikzpicture}
201 \end{tkzexample}
202
203 \subsection{Point relative to another: \tkzcname{tkzDefShiftPoint}}
204 \begin{NewMacroBox}{tkzDefShiftPoint}{\oarg{Point}\parg{$x,y$}\marg{ref} or \parg{$\alpha$:$d$}\marg{ref}}%
205 \begin{tabular}{lll}%
206 arguments & default & definition \\
207 \midrule
208 \TAline{($x,y$)}{no default}{$x$ and $y$ are two dimensions, by default in cm.}
209 \TAline{($\alpha$:$d$)}{no default}{$\alpha$ is an angle in degrees, $d$ is a dimension}
210 \TAline{\{ref\}}{no default}{Reference assigned to the point: $A$, $T\_a$ ,$P1$ or $P_1$}
211
212 \midrule
213 options & default & definition \\
214
215 \midrule
216 \TOline{[pt]} {no default} {\tkzcname{tkzDefShiftPoint}[A](0:4)\{B\}}
217 \end{tabular}
218 \end{NewMacroBox}
219
220 \subsubsection{Isosceles triangle}
221 This macro allows you to place one point relative to another. This is equivalent to a translation. Here is how to construct an isosceles triangle with main vertex $A$ and angle at vertex of $30^{\circ} $.
222
223 \begin{tkzexample}[latex=7cm,small]
224 \begin{tikzpicture}[rotate=-30]
225 \tkzDefPoint(2,3){A}
226 \tkzDefShiftPoint[A](0:4){B}
227 \tkzDefShiftPoint[A](30:4){C}
228 \tkzDrawSegments(A,B B,C C,A)
229 \tkzMarkSegments[mark=|](A,B A,C)
230 \tkzDrawPoints(A,B,C)
231 \tkzLabelPoints[right](B,C)
232 \tkzLabelPoints[above left](A)
233 \end{tikzpicture}
234 \end{tkzexample}
235
236 \subsubsection{Equilateral triangle}
237 Let's see how to get an equilateral triangle (there is much simpler)
238
239 \begin{tkzexample}[latex=7cm,small]
240 \begin{tikzpicture}[scale=1]
241 \tkzDefPoint(2,3){A}
242 \tkzDefShiftPoint[A](30:3){B}
243 \tkzDefShiftPoint[A](-30:3){C}
244 \tkzDrawPolygon(A,B,C)
245 \tkzDrawPoints(A,B,C)
246 \tkzLabelPoints[right](B,C)
247 \tkzLabelPoints[above left](A)
248 \tkzMarkSegments[mark=|](A,B A,C B,C)
249 \end{tikzpicture}
250 \end{tkzexample}
251
252 \subsubsection{Parallelogram}
253 There's a simpler way
254 \begin{tkzexample}[latex=7cm,small]
255 \begin{tikzpicture}
256 \tkzDefPoint(0,0){A}
257 \tkzDefPoint(30:3){B}
258 \tkzDefShiftPointCoord[B](10:2){C}
259 \tkzDefShiftPointCoord[A](10:2){D}
260 \tkzDrawPolygon(A,...,D)
261 \tkzDrawPoints(A,...,D)
262 \end{tikzpicture}
263 \end{tkzexample}
264
265 \subsection{Definition of multiple points: \tkzcname{tkzDefPoints}}
266
267 \begin{NewMacroBox}{tkzDefPoints}{\oarg{local options}\marg{$x_1/y_1/n_1,x_2/y_2/r_2$, ...}}%
268 $x_i$ and $y_i$ are the coordinates of a referenced point $r_i$
269
270 \begin{tabular}{lll}%
271 \toprule
272 arguments & default & example \\
273 \midrule
274 \TAline{$x_i/y_i/r_i$}{}{\tkzcname{tkzDefPoints\{0/0/O,2/2/A\}}}
275 \end{tabular}
276
277 \medskip
278 \begin{tabular}{lll}%
279 options & default & definition \\
280 \midrule
281 \TOline{shift} {no default} {Adds $(x,y)$ or $(\alpha:d)$ to all coordinates}
282 \end{tabular}
283 \end{NewMacroBox}
284
285 \subsection{Create a triangle}
286 \begin{tkzexample}[latex=6cm,small]
287 \begin{tikzpicture}[scale=.75]
288 \tkzDefPoints{0/0/A,4/0/B,4/3/C}
289 \tkzDrawPolygon(A,B,C)
290 \tkzDrawPoints(A,B,C)
291 \end{tikzpicture}
292 \end{tkzexample}
293
294 \subsection{Create a square}
295 Note here the syntax for drawing the polygon.
296 \begin{tkzexample}[latex=6cm,small]
297 \begin{tikzpicture}[scale=1]
298 \tkzDefPoints{0/0/A,2/0/B,2/2/C,0/2/D}
299 \tkzDrawPolygon(A,...,D)
300 \tkzDrawPoints(A,...,D)
301 \end{tikzpicture}
302 \end{tkzexample}
303
304 \endinput