tkz-euclide
Points
13 Random points¶
A random point can be placed:
in a rectangle;
on a segment;
on a straight line;
on a circle;
in a disc.
13.1 Obtaining random points¶
This macro replaces the old \tkzGetRandPointOn.
\tkzDefRandPointOn[⟨local options⟩]¶
The result is a point with a random position, which you can name with the macro \tkzGetPoint. You can use tkzPointResult directly if you don’t need to keep the result.
| options | default | definition |
|---|---|---|
| rectangle=pt1 and pt2 | [rectangle=A and B] | |
| segment= pt1–pt2 | [segment=A–B] | |
| line=pt1–pt2 | [line=A–B] | |
| circle =center pt1 radius dim | [circle = center A radius 2] | |
| circle through=center pt1 through pt2 | [circle through= center A through B] | |
| disk through=center pt1 through pt2 | [disk through=center A through B] |
13.1.1 Random point in a rectangle¶
\begin{tikzpicture}
\tkzDefPoints{0/0/A,5/3/C}
\tkzDefRandPointOn[rectangle = A and C]
\tkzGetPoint{E}
\tkzDefRectangle(A,C)\tkzGetPoints{B}{D}
\tkzDrawPolygon[red](A,...,D)
\tkzDrawPoints(A,...,E)
\tkzLabelPoints(A,B)
\tkzLabelPoints[above](C,D,E)
\end{tikzpicture}
13.1.2 Random point on a segment or a line¶
\begin{tikzpicture}
\tkzDefPoints{0/0/A,5/2/C}
\tkzDefRandPointOn[segment = A--C]\tkzGetPoint{B}
\tkzDrawLine(A,C)
\tkzDrawPoints(A,C) \tkzDrawPoint[red](B)
\tkzLabelPoints(A,C) \tkzLabelPoints[red](B)
\end{tikzpicture}
13.1.3 Random point on a circle or a disk¶
\begin{tikzpicture}
\tkzDefPoints{3/2/A,1/1/B}
\tkzCalcLength(A,B) \tkzGetLength{rAB}
\tkzDefRandPointOn[circle = center A radius \rAB]
\tkzGetPoint{C}
\tkzDefRandPointOn[circle through= center A through B]
\tkzGetPoint{D}
\tkzDefRandPointOn[disk through=center A through B]
\tkzGetPoint{E}
\tkzDrawCircle(A,B)
\tkzDrawPoints(A,B)
\tkzLabelPoints(A,B)
\tkzDrawPoints[red](C,D,E)
\tkzLabelPoints[red,right](C,D,E)
\end{tikzpicture}