tkz-euclide
Complements
41 Miscellaneous and mathematical tools¶
41.1 Duplicate a segment¶
The aim is to construct, on a given ray, a segment of the same length as a given segment.
\tkzDuplicateSegment(⟨pt1,pt2⟩)(⟨pt3,pt4⟩){⟨pt5⟩}¶
This macro constructs, on a given ray, a segment of the same length as a given segment. In fact it defines a point. \tkzDuplicateSegment is the new name of \tkzDuplicateLen.
| arguments | example | explanation |
|---|---|---|
| (pt1,pt2)(pt3,pt4){pt5} | \tkzDuplicateSegment(A,B)(E,F){C} | AC=EF and \(C \in [AB)\) |
The macro \tkzDuplicateLength is identical to this one.
41.1.1 Use of \tkzDuplicateSegment¶
\begin{tikzpicture}[scale=.5]
\tkzDefPoints{0/0/A,2/-3/B,2/5/C}
\tkzDuplicateSegment(A,B)(A,C)
\tkzGetPoint{D}
\tkzDrawSegments[new](A,B A,C)
\tkzDrawSegment[teal](A,D)
\tkzDrawPoints[new](A,B,C,D)
\tkzLabelPoints[above right=3pt](A,B,C,D)
\end{tikzpicture}
41.1.2 Golden ratio with \tkzDuplicateSegment¶
\begin{tikzpicture}[rotate=-90,scale=.4]
\tkzDefPoints{0/0/A,10/0/B}
\tkzDefMidPoint(A,B)
\tkzGetPoint{I}
\tkzDefPointWith[orthogonal,K=-.75](B,A)
\tkzGetPoint{C}
\tkzInterLC(B,C)(B,I) \tkzGetSecondPoint{D}
\tkzDuplicateSegment(B,D)(D,A) \tkzGetPoint{E}
\tkzInterLC(A,B)(A,E) \tkzGetPoints{N}{M}
\tkzDrawArc[orange,delta=10](D,E)(B)
\tkzDrawArc[orange,delta=10](A,M)(E)
\tkzDrawLines(A,B B,C A,D)
\tkzDrawArc[orange,delta=10](B,D)(I)
\tkzDrawPoints(A,B,D,C,M,I)
\tkzLabelPoints[below left](A,B,D,C,M,I)
\end{tikzpicture}
41.1.3 Golden triangle or sublime triangle¶
\begin{tikzpicture}[scale=.75]
\tkzDefPoints{0/0/A,5/0/C,0/5/B}
\tkzDefMidPoint(A,C)\tkzGetPoint{H}
\tkzDuplicateSegment(H,B)(H,A)\tkzGetPoint{D}
\tkzDuplicateSegment(A,D)(A,B)\tkzGetPoint{E}
\tkzDuplicateSegment(A,D)(B,A)\tkzGetPoint{G}
\tkzInterCC(A,C)(B,G)\tkzGetSecondPoint{F}
\tkzDrawLine(A,C)
\tkzDrawArc(A,C)(B)
\begin{scope}[arc style/.style={color=gray,%
style=dashed}]
\tkzDrawArc(H,B)(D)
\tkzDrawArc(A,D)(B)
\tkzDrawArc(B,G)(F)
\end{scope}
\tkzDrawSegment[dashed](H,B)
\tkzCompass(B,F)
\tkzDrawPolygon[new](A,B,F)
\tkzDrawPoints(A,...,H)
\tkzLabelPoints[below left](A,...,H)
\end{tikzpicture}
41.2 Segment length \tkzCalcLength¶
TikZ has a function named veclen. It calculates \(AB\) if \(A\) and \(B\) are two points.
The only problem is that the TikZ version is not accurate enough in some cases. My version uses the package xfp: it is slower, but more accurate.
\tkzCalcLength[⟨local options⟩](⟨pt1,pt2⟩)¶
You can store the result with the macro \tkzGetLength; for example \tkzGetLength{dAB}
defines the macro \dAB.
| arguments | example | explanation |
|---|---|---|
| (pt1,pt2){name of macro} | \tkzCalcLength(A,B) | \dAB gives \(AB\) in cm |
There is only one option.
| options | default | example |
|---|---|---|
| cm | true | \tkzCalcLength(A,B) After \tkzGetLength{dAB} \dAB gives \(AB\) in cm |
41.2.1 Compass square construction¶
\begin{tikzpicture}[scale=1]
\tkzDefPoint(0,0){A} \tkzDefPoint(4,0){B}
\tkzCalcLength(A,B)\tkzGetLength{dAB}
\tkzDefLine[perpendicular=through A](A,B)
\tkzGetPoint{D}
\tkzDefPointWith[orthogonal,K=-1](B,A)
\tkzGetPoint{F}
\tkzGetPoint{C}
\tkzDrawLine[add= .6 and .2](A,B)
\tkzDrawLine(A,D)
\tkzShowLine[orthogonal=through A,gap=2](A,B)
\tkzMarkRightAngle(B,A,D)
\tkzCompasss(A,D D,C)
\tkzDrawArc[R](B,\dAB)(80,110)
\tkzDrawPoints(A,B,C,D)
\tkzDrawSegments[color=gray,style=dashed](B,C C,D)
\tkzLabelPoints[below left](A,B,C,D)
\end{tikzpicture}
41.2.2 Radius of a circle defined by a diameter¶
The macro \tkzDefCircle[radius](A,B) defines a radius, which we retrieve with \tkzGetLength; the result is in cm.
\begin{tikzpicture}[scale=.5]
\tkzDefPoint(0,0){A}
\tkzDefPoint(3,-4){B}
\tkzDefMidPoint(A,B) \tkzGetPoint{M}
\tkzCalcLength(M,B)\tkzGetLength{rAB}
\tkzDrawCircle(A,B)
\tkzDrawPoints(A,B)
\tkzLabelPoints(A,B)
\tkzDrawSegment[dashed](A,B)
\tkzLabelSegment(A,B){$\pgfmathprintnumber{\rAB}$}
\end{tikzpicture}
41.3 Transformation from pt to cm or cm to pt¶
These macros are simple: a division or a multiplication by 28.45274. They are:
\tkzpttocm(⟨number⟩){⟨name of macro⟩}¶
The result is stored in a macro.
| arguments | example | explanation |
|---|---|---|
| (number){name of macro} | \tkzpttocm(120){len} | \len gives a number of tkznamecm |
You have to use \len with the unit cm.
41.4 Change of unit¶
\tkzcmtopt(⟨number⟩){⟨name of macro⟩}¶
The result is stored in a macro.
| arguments | example | explanation |
|---|---|---|
| (number){name of macro} | \tkzcmtopt(5){len} | \len length in pts |
The result can be used with \len pt
41.5 Get point coordinates¶
\tkzGetPointCoord(⟨\(A\)⟩){⟨name of macro⟩}¶
| arguments | example | explanation |
|---|---|---|
| (point){name of macro} | \tkzGetPointCoord(A){A} | \Ax and \Ay give coordinates for \(A\) |
Stores the coordinates of a point in two macros. If the name given is p, then \px and \py give the coordinates of the point, in cm.
41.5.1 Coordinate transfer with \tkzGetPointCoord¶
\begin{tikzpicture}
\tkzInit[xmax=5,ymax=3]
\tkzGrid[sub,orange]
\tkzDrawX \tkzDrawY
\tkzDefPoint(1,0){A}
\tkzDefPoint(4,2){B}
\tkzGetPointCoord(A){a}
\tkzGetPointCoord(B){b}
\tkzDefPoint(\ax,\ay){C}
\tkzDefPoint(\bx,\by){D}
\tkzDrawPoints[color=red](C,D)
\end{tikzpicture}
41.5.2 Sum of vectors with \tkzGetPointCoord¶
\begin{tikzpicture}[>=latex]
\tkzDefPoint(1,4){a}
\tkzDefPoint(3,2){b}
\tkzDefPoint(1,1){c}
\tkzDrawSegment[->,red](a,b)
\tkzGetPointCoord(c){c}
\draw[color=blue,->](a) -- ([shift=(b)]\cx,\cy) ;
\draw[color=purple,->](b) -- ([shift=(b)]\cx,\cy) ;
\tkzDrawSegment[->,blue](a,c)
\tkzDrawSegment[->,purple](b,c)
\end{tikzpicture}
41.6 Swap labels of points¶
\tkzSwapPoints(⟨\(pt1\),\(pt2\)⟩)¶
| arguments | example | explanation |
|---|---|---|
| (pt1,pt2) | \tkzSwapPoints(A,B) | now \(A\) has the coordinates of \(B\) |
The points have exchanged their coordinates.
41.6.1 Use of \tkzSwapPoints¶
\begin{tikzpicture}
\tkzDefPoints{0/0/O,5/-1/A,2/2/B}
\tkzSwapPoints(A,B)
\tkzDrawPoints(O,A,B)
\tkzLabelPoints(O,A,B)
\end{tikzpicture}
41.7 Dot Product¶
In Euclidean geometry, the dot product of two vectors, computed from their Cartesian coordinates, is widely used.
\tkzDotProduct(⟨\(pt1\),\(pt2\),\(pt3\)⟩)¶
The dot product of two vectors \(\overrightarrow{u} = [a,b]\) and \(\overrightarrow{v} = [a',b']\) is defined as: \(\overrightarrow{u}\cdot \overrightarrow{v} = aa' + bb'\)
\(\overrightarrow{u} = \overrightarrow{pt1pt2}\) \(\overrightarrow{v} = \overrightarrow{pt1pt3}\)
| arguments | example | explanation |
|---|---|---|
| (pt1,pt2,pt3) | \tkzDotProduct(A,B,C) | the result is \(\overrightarrow{AB}\cdot \overrightarrow{AC}\) |
The result is a number that can be retrieved with \tkzGetResult.
41.7.1 Simple example¶
\begin{tikzpicture}
\tkzDefPoints{-2/-3/A,4/0/B,1/3/C}
\tkzDefPointBy[projection= onto A--B](C)
\tkzGetPoint{H}
\tkzDrawSegment(C,H)
\tkzMarkRightAngle(C,H,A)
\tkzDrawSegments[vector style](A,B A,C)
\tkzDrawPoints(A,H) \tkzLabelPoints(A,B,H)
\tkzLabelPoints[above](C)
\tkzDotProduct(A,B,C) \tkzGetResult{pabc}
% \pgfmathparse{round(10*\pabc)/10}
\let\pabc\pgfmathresult
\node at (1,-3) {$\overrightarrow{PA}\cdot \overrightarrow{PB}=\pabc$};
\tkzDotProduct(A,H,B) \tkzGetResult{phab}
% \pgfmathparse{round(10*\phab)/10}
\let\phab\pgfmathresult
\node at (1,-4) {$PA \times PH = \phab $};
\end{tikzpicture}
41.7.2 Cocyclic points¶
\begin{tikzpicture}[scale=.75]
\tkzDefPoints{1/2/O,5/2/B,2/2/P,3/3/Q}
\tkzInterLC[common=B](O,B)(O,B) \tkzGetFirstPoint{A}
\tkzInterLC[common=B](P,Q)(O,B) \tkzGetPoints{C}{D}
\tkzDrawCircle(O,B)
\tkzDrawSegments(A,B C,D)
\tkzDrawPoints(A,B,C,D,P)
\tkzLabelPoints(P)
\tkzLabelPoints[below left](A,C)
\tkzLabelPoints[above right](B,D)
\tkzDotProduct(P,A,B) \tkzGetResult{pab}
\pgfmathparse{round(10*\pab)/10}
\let\pab\pgfmathresult
\tkzDotProduct(P,C,D) \tkzGetResult{pcd}
\pgfmathparse{round(10*\pcd)/10}
\let\pcd\pgfmathresult
\node at (1,-3) {%
$\overrightarrow{PA}\cdot \overrightarrow{PB} =
\overrightarrow{PC}\cdot \overrightarrow{PD}$};
\node at (1,-4)%
{$\overrightarrow{PA}\cdot \overrightarrow{PB}=\pab$};
\node at (1,-5){%
$\overrightarrow{PC}\cdot \overrightarrow{PD} =\pcd$};
\end{tikzpicture}
41.8 Power of a point with respect to a circle¶
\tkzPowerCircle(⟨\(pt1\)⟩)(⟨\(pt2\),\(pt3\)⟩)¶
| arguments | example | explanation |
|---|---|---|
| (pt1)(pt2,pt3) | \tkzPowerCircle(A)(O,M) | power of \(A\) with respect to the circle (O,A) |
The result is a number that represents the power of a point with respect to a circle.
41.8.1 Power from the radical axis¶
In this example, the radical axis \((EF)\) has been drawn. A point \(H\) has been chosen on \((EF)\), and the power of \(H\) with respect to the circle with center \(A\) has been calculated, as well as \(HS^2\). You can check that the power of \(H\) with respect to the circle with center \(C\), and \(HS'^2\), \(HT^2\), \(HT'^2\), give the same result.
\begin{tikzpicture}[scale=.5]
\tkzDefPoints{-1/0/A,0/5/B,5/-1/C,7/1/D}
\tkzDrawCircles(A,B C,D)
\tkzDefRadicalAxis(A,B)(C,D) \tkzGetPoints{E}{F}
\tkzDrawLine[add=1 and 2](E,F)
\tkzDefPointOnLine[pos=1.5](E,F)
\tkzGetPoint{H}
\tkzDefLine[tangent from = H](A,B)
\tkzGetPoints{T}{T'}
\tkzDefLine[tangent from = H](C,D)
\tkzGetPoints{S}{S'}
\tkzDrawSegments(H,T H,T' H,S H,S')
\tkzDrawPoints(A,B,C,D,E,F,H,T,T',S,S')
\tkzPowerCircle(H)(A,B) \tkzGetResult{pw}
\tkzDotProduct(H,S,S) \tkzGetResult{phtt}
\node {Power $\approx \pw \approx \phtt$};
\end{tikzpicture}
41.9 Radical axis¶
In geometry, the radical axis of two non-concentric circles is the set of points that have the same power with respect to both circles. Here \tkzDefRadicalAxis(A,B)(C,D) gives the radical axis of the two circles \(\mathcal{C}(A,B)\) and \(\mathcal{C}(C,D)\).
\tkzDefRadicalAxis(⟨\(pt1\),\(pt2\)⟩)(⟨\(pt3\),\(pt4\)⟩)¶
| arguments | example | explanation |
|---|---|---|
| (pt1,pt2)(pt3,pt4) | \tkzDefRadicalAxis(A,B)(C,D) | Two circles with centers \(A\) and \(C\) |
The result is two points of the radical axis.
41.9.1 Two disjoint circles¶
\begin{tikzpicture}[scale=.75]
\tkzDefPoints{-1/0/A,0/2/B,4/-1/C,4/0/D}
\tkzDrawCircles(A,B C,D)
\tkzDefRadicalAxis(A,B)(C,D)
\tkzGetPoints{E}{F}
\tkzDrawLine[add=1 and 2](E,F)
\tkzDrawLine[add=.5 and .5](A,C)
\end{tikzpicture}
41.9.2 Two intersecting circles¶
\begin{tikzpicture}[scale=.5]
\tkzDefPoints{-1/0/A,0/2/B,3/-1/C,3/-2/D}
\tkzDrawCircles(A,C B,D)
\tkzDefRadicalAxis(A,C)(B,D)
\tkzGetPoints{E}{F}
\tkzDrawPoints(A,B,C,D,E,F)
\tkzLabelPoints(A,B,C,D,E,F)
\tkzDrawLine[add=.25 and .5](E,F)
\tkzDrawLine[add=.25 and .25](A,B)
\end{tikzpicture}
41.9.3 Two externally tangent circles¶
\begin{tikzpicture}[scale=.5]
\tkzDefPoints{0/0/A,4/0/B,6/0/C}
\tkzDrawCircles(A,B C,B)
\tkzDefRadicalAxis(A,B)(C,B)
\tkzGetPoints{E}{F}
\tkzDrawPoints(A,B,C,E,F)
\tkzLabelPoints(A,B,C,E,F)
\tkzDrawLine[add=1 and 1](E,F)
\tkzDrawLine[add=.5 and .5](A,B)
\end{tikzpicture}
41.9.4 Two internally tangent circles¶
\begin{tikzpicture}[scale=.5]
\tkzDefPoints{0/0/A,3/0/B,5/0/C}
\tkzDrawCircles(A,C B,C)
\tkzDefRadicalAxis(A,C)(B,C)
\tkzGetPoints{E}{F}
\tkzDrawPoints(A,B,C,E,F)
\tkzLabelPoints[below right](A,B,C,E,F)
\tkzDrawLine[add=1 and 1](E,F)
\tkzDrawLine[add=.5 and .5](A,B)
\end{tikzpicture}
41.9.5 Three circles¶
\begin{tikzpicture}[scale=.4]
\tkzDefPoints{0/0/A,5/0/a,7/-1/B,3/-1/b,5/-4/C,2/-4/c}
\tkzDrawCircles(A,a B,b C,c)
\tkzDefRadicalAxis(A,a)(B,b) \tkzGetPoints{i}{j}
\tkzDefRadicalAxis(A,a)(C,c) \tkzGetPoints{k}{l}
\tkzDefRadicalAxis(C,c)(B,b) \tkzGetPoints{m}{n}
\tkzDrawLines[new](i,j k,l m,n)
\end{tikzpicture}
41.10 \tkzIsLinear, \tkzIsOrtho¶
\tkzIsLinear(⟨\(pt1\),\(pt2\),\(pt3\)⟩)¶
| arguments | example | explanation |
|---|---|---|
| (pt1,pt2,pt3) | \tkzIsLinear(A,B,C) | \(A,B,C\) aligned ? |
\tkzIsLinear tests whether the three points \(pt1\), \(pt2\), \(pt3\) are aligned. The test tolerates an angle of about \(0.06^\circ\).
\tkzIsOrtho(⟨\(pt1\),\(pt2\),\(pt3\)⟩)¶
| arguments | example | explanation |
|---|---|---|
| (pt1,pt2,pt3) | \tkzIsOrtho(A,B,C) | \((AB)\perp (AC)\) ? |
\tkzIsOrtho tests whether the lines \((pt1pt2)\) and \((pt1pt3)\) are orthogonal, with the same tolerance.
41.10.1 Use of \tkzIsOrtho and \tkzIsLinear¶
\begin{tikzpicture}
\tkzDefPoints{1/-2/A,5/0/B}
\tkzDefCircle[diameter](A,B) \tkzGetPoint{O}
\tkzDrawCircle(O,A)
\tkzDefPointBy[rotation= center O angle 60](B)
\tkzGetPoint{C}
\tkzDefPointBy[rotation= center O angle 60](A)
\tkzGetPoint{D}
\tkzDrawCircle(O,A)
\tkzDrawPoints(A,B,C,D,O)
\tkzIsOrtho(C,A,B)
\iftkzOrtho
\tkzDrawPolygon[blue](A,B,C)
\tkzDrawPoints[blue](A,B,C,D)
\else
\tkzDrawPoints[red](A,B,C,D)
\fi
\tkzIsLinear(O,C,D)
\iftkzLinear
\tkzDrawSegment[orange](C,D)
\fi
\end{tikzpicture}