summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tkz/tkz-euclide/doc/latex/TKZdoc-euclide-rnd.tex
blob: 37e0fdb6badf2a1faa2a58f38b2c604bb5ff95b0 (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
\section{Random point definition}
%<--------------------------------------------------------------------------->
%           points random
%<--------------------------------------------------------------------------->
At the moment there are four possibilities:
\begin{enumerate}
  \item point in a rectangle,
  \item on a segment,
  \item on a straight line,
  \item on a circle.
\end{enumerate}

\subsection{Obtaining random points}
This is the new version that replaces  \tkzcname{tkzGetRandPointOn}
\begin{NewMacroBox}{tkzDefRandPointOn}{\oarg{local options}}
{The result is a point with a random position that can be named with the macro \tkzcname{tkzGetPoint}. It is possible to use \tkzname{tkzPointResult} if it is not necessary to retain the results..}


\medskip
\begin{tabular}{lll}
\toprule
options             & default & definition                         \\ 
\midrule
\TOline{rectangle=pt1 and pt2}  {}{[rectangle=A and B]} 
\TOline{segment= pt1--pt2} {}{[segment=A--B]}
\TOline{line=pt1--pt2}{}{[line=A--B]} 
\TOline{circle =center pt1 radius dim}{}{[circle = center A radius 2cm]} 
\TOline{circle through=center pt1 through pt2}{}{[circle through= center A through B]}
\TOline{disk through=center pt1 through pt2}{}{[disk through=center A through B]}
 \bottomrule
\end{tabular}

\end{NewMacroBox} 

\subsection{Random point in a rectangle} 

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
  \tkzInit[xmax=5,ymax=5]\tkzGrid
  \tkzDefPoints{0/0/A,2/2/B,5/5/C}
  \tkzDefRandPointOn[rectangle = A and B]
  \tkzGetPoint{a}
  \tkzDefRandPointOn[rectangle = B and C]
  \tkzGetPoint{d}
  \tkzDrawLine(a,d)
  \tkzDrawPoints(A,B,C,a,d) 
  \tkzLabelPoints(A,B,C,a,d)  
\end{tikzpicture} 
\end{tkzexample} 

\subsection{Random point on a segment}  
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}  
  \tkzInit[xmax=5,ymax=5] \tkzGrid 
  \tkzDefPoints{0/0/A,2/2/B,3/3/C,5/5/D}  
  \tkzDefRandPointOn[segment = A--B]\tkzGetPoint{a}
  \tkzDefRandPointOn[segment = C--D]\tkzGetPoint{d}
  \tkzDrawPoints(A,B,C,D,a,d) 
  \tkzLabelPoints(A,B,C,D,a,d)
\end{tikzpicture}
\end{tkzexample}

\subsection{Random point on a straight line}
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
  \tkzInit[xmax=5,ymax=5] \tkzGrid
  \tkzDefPoints{0/0/A,2/2/B,3/3/C,5/5/D}  
  \tkzDefRandPointOn[line = A--B]\tkzGetPoint{a}
  \tkzDefRandPointOn[line = C--D]\tkzGetPoint{d}
  \tkzDrawPoints(A,B,C,D,a,d)
  \tkzLabelPoints(A,B,C,D,a,d)
\end{tikzpicture}
\end{tkzexample}


\subsubsection{Example of random points}
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}
 \tkzDefPoints{0/0/A,2/2/B,-1/-1/C}
 \tkzDefCircle[through=](A,C) 
 \tkzGetLength{rAC}
 \tkzDrawCircle(A,C)
 \tkzDrawCircle(A,B)
 \tkzDefRandPointOn[rectangle=A and B]
 \tkzGetPoint{a}
 \tkzDefRandPointOn[segment=A--B]
 \tkzGetPoint{b}
 \tkzDefRandPointOn[circle=center A radius \rAC pt]
    \tkzGetPoint{d}
 \tkzDefRandPointOn[circle through= center A through B]
     \tkzGetPoint{c}
 \tkzDefRandPointOn[disk through=center A through B]
     \tkzGetPoint{e}
 \tkzLabelPoints[above right=3pt](A,B,C,a,b,...,e)
 \tkzDrawPoints[](A,B,C,a,b,...,e)
 \tkzDrawRectangle(A,B)
\end{tikzpicture}
\end{tkzexample}

\subsection{Random point on a circle}
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture} 
  \tkzInit[xmax=5,ymax=5]  \tkzGrid   
  \tkzDefPoints{3/2/A,1/1/B}
  \tkzCalcLength[cm](A,B) \tkzGetLength{rAB}
  \tkzDrawCircle[R](A,\rAB cm) 
  \tkzDefRandPointOn[circle = center A radius
   \rAB cm]\tkzGetPoint{a}
  \tkzDrawSegment(A,a)
  \tkzDrawPoints(A,B,a) 
  \tkzLabelPoints(A,B,a)  
\end{tikzpicture}
\end{tkzexample}

\subsubsection{Random example and circle of Apollonius}
\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}[scale=1]
 \tkzDefPoints{0/0/A,3/0/B}
 \def\coeffK{2}
 \tkzApolloniusCenter[K=\coeffK](A,B) 
 \tkzGetPoint{P}
 \tkzDefApolloniusPoint[K=\coeffK](A,B) 
 \tkzGetPoint{M}
 \tkzDefApolloniusRadius[K=\coeffK](A,B)
 \tkzDrawCircle[R,color = blue!50!black,
     fill=blue!20,
     opacity=.4](tkzPointResult,\tkzLengthResult pt)
 \tkzDefRandPointOn[circle through= center P through M]
 \tkzGetPoint{N}
 \tkzDrawPoints(A,B,P,M,N)
 \tkzLabelPoints(A,B,P,M,N)
 \tkzDrawSegments[red](N,A N,B)
 \tkzDrawPoints(A,B)
 \tkzDrawSegments[red](A,B)
 \tkzLabelCircle[R,draw,fill=green!10,%
     text width=3cm,%
     text centered](P,\tkzLengthResult pt-20pt)(-120)%
  { $MA/MB=\coeffK$\\$NA/NB=\coeffK$}
\end{tikzpicture}
\end{tkzexample}



\subsection{Middle of a compass segment}
 To conclude this section, here is a more complex example. It involves determining the middle of a segment, using only a compass. 

\begin{tkzexample}[latex=7cm,small]
\begin{tikzpicture}[scale=.75]
  \tkzDefPoint(0,0){A}
  \tkzDefRandPointOn[circle= center A radius 4cm]
  \tkzGetPoint{B}
  \tkzDrawPoints(A,B)
  \tkzDefPointBy[rotation= center A angle 180](B) 
  \tkzGetPoint{C}
  \tkzInterCC[R](A,4 cm)(B,4 cm)
  \tkzGetPoints{I}{I'}
  \tkzInterCC[R](A,4 cm)(I,4 cm)
  \tkzGetPoints{J}{B}
  \tkzInterCC(B,A)(C,B)
  \tkzGetPoints{D}{E}
  \tkzInterCC(D,B)(E,B)
  \tkzGetPoints{M}{M'}
  \tikzset{arc/.style={color=brown,style=dashed,delta=10}}
  \tkzDrawArc[arc](C,D)(E)
  \tkzDrawArc[arc](B,E)(D)
  \tkzDrawCircle[color=brown,line width=.2pt](A,B)
  \tkzDrawArc[arc](D,B)(M) 
  \tkzDrawArc[arc](E,M)(B)
  \tkzCompasss[color=red,style=solid](B,I I,J J,C)
  \tkzDrawPoints(B,C,D,E,M)
  \tkzLabelPoints(A,B,M)
 \end{tikzpicture}
 \end{tkzexample}
   
\endinput