summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/tkz-euclide/TKZdoc-euclide-points.tex
blob: 2741872f8c00651226e0eeaa3e819a51f5bcc86e (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
\section{First step: fixed points}

The first step in a geometric construction is to define the fixed points from which the figure will be constructed.

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.

\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.

A point in \tkzname{\tkznameofpack} is a particular "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}.


\section{Definition of a point : \tkzcname{tkzDefPoint} or \tkzcname{tkzDefPoints}}

 Points can be specified in any of the following ways:
\begin{itemize}
\item Cartesian coordinates;
\item Polar coordinates;
\item Named points;
\item Relative points.
\end{itemize}


A point is defined if it has a name linked to a unique pair of decimal numbers. 
 Let $(x,y)$ or $(a:d)$  i.e. ($x$ abscissa, $y$ ordinate) or  ($a$ angle: $d$ distance).
 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.
 
 The Cartesian coordinate $(a,b)$ refers to the
 point $a$ centimeters in the $x$-direction and $b$ centimeters in the
 $y$-direction.

 A point in polar coordinates requires an angle $\alpha$, in degrees,
 and a distance  $d$ from the origin with a dimensional
 unit by default it's the \texttt{cm}.
 
 The \tkzNameMacro{tkzDefPoint} macro is used to define a point by assigning coordinates to it. This macro is based on 
 
 \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.
 
\begin{minipage}[t]{0.45\textwidth}
 Cartesian coordinates 
\begin{tkzexample}[code only,small]
\begin{tikzpicture}[scale=1] 
  \tkzInit[xmax=5,ymax=5]
  % necessary to limit
  % the size of the axes
  \tkzDrawX[>=latex]
  \tkzDrawY[>=latex]
  \tkzDefPoints{0/0/O,1/0/I,0/1/J}
  \tkzDefPoint(3,4){A} 
  \tkzDrawPoints(O,A) 
  \tkzLabelPoint[above](A){$A_1 (x_1,y_1)$} 
  \tkzShowPointCoord[xlabel=$x_1$,
                     ylabel=$y_1$](A) 
  \tkzLabelPoints(O,I)
  \tkzLabelPoints[left](J)
  \tkzDrawPoints[shape=cross](I,J) 
\end{tikzpicture}
\end{tkzexample}%
\end{minipage}
\begin{minipage}[t]{0.45\textwidth}
 Polar coordinates
\begin{tkzexample}[code only,small]
\begin{tikzpicture}[,scale=1]
  \tkzInit[xmax=5,ymax=5]
  \tkzDrawX[>=latex]
  \tkzDrawY[>=latex]  
  \tkzDefPoints{0/0/O,1/0/I,0/1/J}
  \tkzDefPoint(40:4){P} 
  \tkzDrawSegment[dim={$d$,
                 16pt,above=6pt}](O,P)
  \tkzDrawPoints(O,P) 
  \tkzMarkAngle[mark=none,->](I,O,P) 
  \tkzFillAngle[opacity=.5](I,O,P) 
  \tkzLabelAngle[pos=1.25](I,O,P){%
                              $\alpha$}  
  \tkzLabelPoint[right](P){$P  (\alpha : d )$} 
  \tkzDrawPoints[shape=cross](I,J) 
  \tkzLabelPoints(O,I)
  \tkzLabelPoints[left](J) 
\end{tikzpicture}
\end{tkzexample}
\end{minipage}%

\begin{minipage}[b]{0.45\textwidth}
\begin{tikzpicture}[scale=1] 
  \tkzInit[xmax=5,ymax=5]
  \tkzDrawX[>=latex]
  \tkzDrawY[>=latex]
  \tkzDefPoints{0/0/O,1/0/I,0/1/J}
  \tkzDefPoint(3,4){A} 
  \tkzDrawPoints(O,A) 
  \tkzLabelPoint[above](A){$A_1 (x_1,y_1)$} 
  \tkzShowPointCoord[xlabel=$x_1$,ylabel=$y_1$](A) 
  \tkzLabelPoints(O,I)
  \tkzLabelPoints[left](J)
  \tkzDrawPoints[shape=cross](I,J) 
\end{tikzpicture}
\end{minipage}
\begin{minipage}[b]{0.45\textwidth}
\begin{tikzpicture}[,scale=1]
  \tkzInit[xmax=5,ymax=5]
  \tkzDrawX[>=latex]
  \tkzDrawY[>=latex]  
  \tkzDefPoints{0/0/O,1/0/I,0/1/J}
  \tkzDefPoint(40:4){P} 
  \tkzDrawSegment[dim={$d$,
                 16pt,above=6pt}](O,P)
  \tkzDrawPoints(O,P) 
  \tkzMarkAngle[mark=none,->](I,O,P) 
  \tkzFillAngle[opacity=.5](I,O,P) 
  \tkzLabelAngle[pos=1.25](I,O,P){$\alpha$}  
  \tkzLabelPoint[right](P){$P  (\alpha : d )$} 
  \tkzDrawPoints[shape=cross](I,J) 
  \tkzLabelPoints(O,I)
  \tkzLabelPoints[left](J) 
\end{tikzpicture}
\end{minipage}%

\subsection{Defining a named point  \tkzcname{tkzDefPoint}}

\begin{NewMacroBox}{tkzDefPoint}{\oarg{local options}\parg{$x,y$}\marg{ref} or \parg{$\alpha$:$d$}\marg{ref}}%
\begin{tabular}{lll}%
arguments &  default & definition  \\ 
\midrule
\TAline{($x,y$)}{no default}{$x$ and $y$ are two dimensions, by default in cm.}
\TAline{($\alpha$:$d$)}{no default}{$\alpha$ is an angle in degrees, $d$ is a dimension}
\TAline{\{ref\}}{no default}{Reference assigned to the point: $A$, $T\_a$ ,$P1$ or $P_1$}
\bottomrule
\end{tabular}

\medskip
\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.}

\medskip
\begin{tabular}{lll}%
\toprule
options             & default & definition  \\ 
\midrule
\TOline{label} {no default} {allows you to place a label at a predefined distance}
\TOline{shift} {no default} {adds $(x,y)$ or $(\alpha:d)$ to all coordinates}
\end{tabular}
\end{NewMacroBox}

\subsubsection{Cartesian coordinates }
 
\begin{tkzexample}[latex=5cm,small]
  \begin{tikzpicture}
  \tkzInit[xmax=5,ymax=5] % limits the size of the axes
  \tkzDrawX[>=latex]
  \tkzDrawY[>=latex]  
  \tkzDefPoint(0,0){A}
  \tkzDefPoint(4,0){B}
  \tkzDefPoint(0,3){C} 
  \tkzDrawPolygon(A,B,C)
  \tkzDrawPoints(A,B,C)
  \end{tikzpicture}
\end{tkzexample}

\subsubsection{Calculations with \tkzNamePack{xfp}}

 \begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}[scale=1]
  \tkzInit[xmax=4,ymax=4]
  \tkzDrawX\tkzDrawY
  \tkzDefPoint(-1+2,sqrt(4)){O}
  \tkzDefPoint({3*ln(exp(1))},{exp(1)}){A}
  \tkzDefPoint({4*sin(pi/6)},{4*cos(pi/6)}){B}
  \tkzDrawPoints(O,B,A)
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Polar coordinates }

\begin{tkzexample}[latex=7cm,small]
  \begin{tikzpicture}
  \foreach \an [count=\i] in {0,60,...,300}
   { \tkzDefPoint(\an:3){A_\i}}
  \tkzDrawPolygon(A_1,A_...,A_6)
  \tkzDrawPoints(A_1,A_...,A_6)
  \end{tikzpicture}
\end{tkzexample}

\subsubsection{Relative points}
First, we can use the \tkzNameEnv{scope} environment from \TIKZ.
In the following example, we have a way to define an equilateral triangle.

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}[scale=1]
 \begin{scope}[rotate=30]
  \tkzDefPoint(2,3){A}
  \begin{scope}[shift=(A)]
     \tkzDefPoint(90:5){B}
     \tkzDefPoint(30:5){C}
  \end{scope}
 \end{scope}
 \tkzDrawPolygon(A,B,C)
\tkzLabelPoints[above](B,C)
\tkzLabelPoints[below](A)
\tkzDrawPoints(A,B,C)
\end{tikzpicture}
\end{tkzexample}

\subsection{Point relative to another: \tkzcname{tkzDefShiftPoint}}
\begin{NewMacroBox}{tkzDefShiftPoint}{\oarg{Point}\parg{$x,y$}\marg{ref} or \parg{$\alpha$:$d$}\marg{ref}}%
\begin{tabular}{lll}%
arguments &  default & definition \\
\midrule
\TAline{($x,y$)}{no default}{$x$ and $y$ are two dimensions, by default in cm.}
\TAline{($\alpha$:$d$)}{no default}{$\alpha$ is an angle in degrees, $d$ is a dimension}
\TAline{\{ref\}}{no default}{Reference assigned to the point: $A$, $T\_a$ ,$P1$ or $P_1$}

\midrule
options &  default & definition \\

\midrule
\TOline{[pt]} {no default} {\tkzcname{tkzDefShiftPoint}[A](0:4)\{B\}}
\end{tabular}
\end{NewMacroBox}

\subsubsection{Isosceles triangle}
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} $.

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}[rotate=-30]
 \tkzDefPoint(2,3){A}
 \tkzDefShiftPoint[A](0:4){B}
 \tkzDefShiftPoint[A](30:4){C}
 \tkzDrawSegments(A,B B,C C,A)
 \tkzMarkSegments[mark=|](A,B A,C)
 \tkzDrawPoints(A,B,C)
 \tkzLabelPoints[right](B,C)
 \tkzLabelPoints[above left](A)
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Equilateral triangle}
Let's see how to get an equilateral triangle (there is much simpler)

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}[scale=1]
 \tkzDefPoint(2,3){A}
 \tkzDefShiftPoint[A](30:3){B}
 \tkzDefShiftPoint[A](-30:3){C}
 \tkzDrawPolygon(A,B,C)
 \tkzDrawPoints(A,B,C)
 \tkzLabelPoints[right](B,C)
 \tkzLabelPoints[above left](A)
 \tkzMarkSegments[mark=|](A,B A,C B,C)
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Parallelogram}
There's a simpler way
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
 \tkzDefPoint(0,0){A}
 \tkzDefPoint(30:3){B}
 \tkzDefShiftPointCoord[B](10:2){C}
 \tkzDefShiftPointCoord[A](10:2){D}
 \tkzDrawPolygon(A,...,D)
 \tkzDrawPoints(A,...,D)
\end{tikzpicture}
\end{tkzexample}

\subsection{Definition of multiple points: \tkzcname{tkzDefPoints}}

\begin{NewMacroBox}{tkzDefPoints}{\oarg{local options}\marg{$x_1/y_1/n_1,x_2/y_2/r_2$, ...}}%
$x_i$ and $y_i$ are the coordinates of a referenced point $r_i$

\begin{tabular}{lll}%
\toprule
arguments &  default  & example  \\
\midrule
\TAline{$x_i/y_i/r_i$}{}{\tkzcname{tkzDefPoints\{0/0/O,2/2/A\}}}
\end{tabular}

\medskip
\begin{tabular}{lll}%
options             & default & definition   \\ 
\midrule
\TOline{shift} {no default} {Adds $(x,y)$ or $(\alpha:d)$ to all coordinates}
\end{tabular}
\end{NewMacroBox}

\subsection{Create a triangle}
\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}[scale=.75]
 \tkzDefPoints{0/0/A,4/0/B,4/3/C}
 \tkzDrawPolygon(A,B,C)
 \tkzDrawPoints(A,B,C)
\end{tikzpicture}
\end{tkzexample}

\subsection{Create a square}
Note here the syntax for drawing the polygon.
\begin{tkzexample}[latex=6cm,small]
\begin{tikzpicture}[scale=1]
 \tkzDefPoints{0/0/A,2/0/B,2/2/C,0/2/D}
 \tkzDrawPolygon(A,...,D)
 \tkzDrawPoints(A,...,D)
\end{tikzpicture}
\end{tkzexample}

\endinput