tikz.dev / tkz-euclide Manual

tkz-euclide

Intersections and angles

19 Intersections

You can determine the points of intersection of two straight lines, of a straight line and a circle, and of two circles.

The associated commands do not check that the intersection points exist: this is up to the user (see the tests \tkzTestInterLC and \tkzTestInterCC).

19.1 Intersection of two straight lines \tkzInterLL
  • \tkzInterLL(⟨\(A,B\)⟩)(⟨\(C,D\)⟩)

  • Defines the intersection point tkzPointResult of the two lines \((AB)\) and \((CD)\). The known points are given in pairs (two per line) between parentheses, and the resulting point is retrieved with the macro \tkzGetPoint.

19.1.1 Example of intersection between two straight lines

Compiled output

\begin{tikzpicture}[rotate=-45,scale=.75]
\tkzDefPoint(2,1){A}
\tkzDefPoint(6,5){B}
\tkzDefPoint(3,6){C}
\tkzDefPoint(5,2){D}
\tkzDrawLines(A,B C,D)
\tkzInterLL(A,B)(C,D)
\tkzGetPoint{I}
\tkzDrawPoints[color=blue](A,B,C,D)
\tkzDrawPoint[color=red](I)
\end{tikzpicture}
19.2 Intersection of a straight line and a circle \tkzInterLC

As before, the line is defined by a pair of points. The circle is also defined by a pair:

  • \((O,C)\), a pair of points: the first one is the center and the second one is any point of the circle;

  • \((O,r)\), where \(r\) is the radius.

  • \tkzInterLC[⟨options⟩](⟨\(A,B\)⟩)(⟨\(O,C\)⟩) or (⟨\(O,r\)⟩) or (⟨\(O,C,D\)⟩)

  • So the arguments are two pairs.

    optionsdefaultdefinition
    NN(O,C) determines the circle
    RN(O, 1 ) unit 1 cm
    with nodesN(O,C,D) CD is a radius
    common=ptpt is common point; tkzFirstPoint gives the other point
    neartkzFirstPoint is the closest point to the first point of the line

    The macro defines the intersection points \(I\) and \(J\) of the line \((AB)\) and the circle with center \(O\) and radius \(r\), if they exist; otherwise, an error is reported in the .log file. With with nodes, you don’t need to calculate the radius, which is the length of \([CD]\). If common and near are not used, tkzFirstPoint is the point that gives the smallest angle (formed with tkzSecondPoint and the center of the circle).

  • \tkzTestInterLC(⟨\(O,A\)⟩)(⟨\(O',B\)⟩)

  • The arguments are two pairs, which define a line and a circle (with a center and a point of the circle). If the line and the circle intersect, the test \iftkzFlagLC is true.

19.2.1 Testing a line-circle intersection: \tkzTestInterLC

Compiled output

\begin{tikzpicture}[scale=1]
\tkzDefPoints{% x y name
3 /4 /I,
3 /2 /P,
0 /2 /La,
8 /3 /Lb}
\tkzDrawCircle(I,P)
\foreach \i in {1,...,3}{%
\coordinate (Lb) at (8,\i);
\tkzDrawLine(La,Lb)
\tkzTestInterLC(La,Lb)(I,P)
\iftkzFlagLC
\tkzInterLC(La,Lb)(I,P)
\tkzGetPoints{a}{b}
\tkzDrawPoints(a,b)
\fi
}
\end{tikzpicture}
19.2.2 Line-circle intersection

In the following example, the circle is drawn with two points, and the intersection of the straight line and the circle uses two pairs of points. We will compare the angles \(\widehat{D,E,O}\) and \(\widehat{E,D,O}\). These angles have opposite orientations. tkzFirstPoint is assigned to the point that forms the angle with the smallest measure (counterclockwise direction). The counterclockwise angle \(\widehat{D,E,O}\) measures \(360^\circ\) minus the measure of \(\widehat{O,E,D}\).

Compiled output

\begin{tikzpicture}[scale=.75]
\tkzInit[xmax=5,ymax=4]
\tkzDefPoint(1,1){O}
\tkzDefPoint(-2,4){La}
\tkzDefPoint(5,0){Lb}
\tkzDefPoint(3,3){C}
\tkzInterLC(La,Lb)(O,C) \tkzGetPoints{D}{E}
\tkzMarkAngle[->,size=1.5](E,D,O)
\tkzDrawPolygons[new](O,D,E)
\tkzMarkAngle[->,size=1.5](D,E,O)
\tkzDrawCircle(O,C)
\tkzDrawPoints[color=teal](O,La,Lb,C)
\tkzDrawPoints[color=red](D,E)
\tkzDrawLine(La,Lb)
\tkzLabelPoints[above right](O,La,Lb,C,D,E)
\end{tikzpicture}
19.2.3 Line passing through the center: option common

This case is special: the angles cannot be compared, so the option near must be used. tkzFirstPoint is assigned to the point closest to the first point given for the line. Here we want \(A\) to be closest to \(Lb\).

Compiled output

\begin{tikzpicture}
\tkzDefPoints{% x y name
0 /1 /D,
6 /0 /B,
3 /3 /O,
2 /2 /La,
5 /5 /Lb}
\tkzDrawCircle(O,D)
\tkzDrawLine(La,Lb)
\tkzInterLC[near](Lb,La)(O,D)
\tkzGetFirstPoint{A}
\tkzDrawSegments(O,A)
\tkzDrawPoints(O,D,A,La,Lb)
\tkzLabelPoints(O,D,A,La,Lb)
\end{tikzpicture}
19.2.4 Line-circle intersection with option common

A special case that often occurs: a point of the line is on the circle, and we look for the other common point.

Compiled output

\begin{tikzpicture}[scale=.5]
\tkzDefPoints{0/0/O,-5/0/A,2/-2/B,0/5/D}
\tkzInterLC[common=A](B,A)(O,D)
\tkzGetFirstPoint{C}
\tkzDrawPoints(O,A,B)
\tkzDrawCircle(O,A)
\tkzDrawLine(A,C)
\tkzDrawPoint(C)
\tkzLabelPoints(A,B,C)
\end{tikzpicture}
19.2.5 Line-circle intersection: order of the points

The idea is to compare the angles formed by the first point of the line, a resulting point and the center of the circle. The first point is the one that gives the smallest angle.

As you can see, \(\widehat{BCO} < \widehat{BEO}\); in fact, \(\widehat{BEO}\) is counterclockwise.

Compiled output

\begin{tikzpicture}[scale=.5]
\tkzDefPoints{0/0/O,5/1/A,2/2/B,3/1/D}
\tkzInterLC[common=A](B,D)(O,A) \tkzGetPoints{C}{E}
\tkzDrawPoints(O,A,B,D)
\tkzDrawCircle(O,A) \tkzDrawLine(E,C)
\tkzDrawSegments[dashed](B,O O,C)
\tkzMarkAngle[->,size=1.5](B,C,O)
\tkzDrawSegments[dashed](O,E)
\tkzMarkAngle[->,size=1.5](B,E,O)
\tkzDrawPoints(C,E)
\tkzLabelPoints[above](O,E)
\tkzLabelPoints[right](A,B,C,D)
\end{tikzpicture}
19.2.6 Example with \foreach

Compiled output

\begin{tikzpicture}[scale=3,rotate=180]
\tkzDefPoint(0,1){J}
\tkzDefPoint(0,0){O}
\foreach \i in {0,-5,-10,...,-90}{
\tkzDefPoint({2.5*cos(\i*pi/180)},%
{1+2.5*sin(\i*pi/180)}){P}
\tkzInterLC[R](P,J)(O,1)\tkzGetPoints{N}{M}
\tkzDrawSegment[color=orange](J,N)
\tkzDrawPoints[red](N)}
\foreach \i in {-90,-95,...,-175,-180}{
\tkzDefPoint({2.5*cos(\i*pi/180)},%
{1+2.5*sin(\i*pi/180)}){P}
\tkzInterLC[R](P,J)(O,1)\tkzGetPoints{N}{M}
\tkzDrawSegment[color=orange](J,M)
\tkzDrawPoints[red](M)}
\end{tikzpicture}
19.2.7 Line-circle intersection with option near

\(D\) is the point closest to \(b\).

Compiled output

\begin{tikzpicture}
\tkzDefPoints{0/0/A,12/0/C}
\tkzDefGoldenRatio(A,C) \tkzGetPoint{B}
\tkzDefMidPoint(A,C) \tkzGetPoint{O}
\tkzDefMidPoint(A,B) \tkzGetPoint{O_1}
\tkzDefMidPoint(B,C) \tkzGetPoint{O_2}
\tkzDefPointBy[rotation=center O_2 angle 90](C) \tkzGetPoint{P}
\tkzDefPointBy[rotation=center O_1 angle 90](B) \tkzGetPoint{Q}
\tkzDefPointBy[rotation=center B angle 90](C) \tkzGetPoint{b}
\tkzInterLC[near](b,B)(O,A) \tkzGetFirstPoint{D}
\tkzInterCC(D,B)(O,C) \tkzGetPoints{V}{U}
\tkzDefPointBy[projection=onto U--V](O_1) \tkzGetPoint{M}
\tkzDefPointBy[projection=onto U--V](O_2) \tkzGetPoint{N}
\tkzDrawPoints(A,B,C,O,O_1,O_2,D,U,V,M,N,b)
\tkzDrawSemiCircles[teal](O,C O_1,B O_2,C)
\tkzDrawSegments(A,C B,D U,V A,D C,D M,B B,N)
\tkzDrawArc(D,U)(V)
\tkzLabelPoints(A,B,C,O,O_1,O_2)
\tkzLabelPoints[above](D,U,V,M,N)
\end{tikzpicture}
19.2.8 More complex example of a line-circle intersection

Figure from http://gogeometry.com/problem/p190_tangent_circle

Compiled output

\begin{tikzpicture}[scale=.75]
\tkzDefPoint(0,0){A}
\tkzDefPoint(8,0){B}
\tkzDefMidPoint(A,B) \tkzGetPoint{O}
\tkzDefMidPoint(O,B) \tkzGetPoint{O'}
\tkzDefLine[tangent from=A](O',B)\tkzGetFirstPoint{E}
\tkzInterLC(A,E)(O,B) \tkzGetFirstPoint{D}
\tkzDefPointBy[projection=onto A--B](D)
\tkzGetPoint{F}
\tkzDrawCircles(O,B O',B)
\tkzDrawSegments(A,D A,B D,F)
\tkzDrawSegments[color=red,line width=1pt,
opacity=.4](A,O F,B)
\tkzDrawPoints(A,B,O,O',E,D)
\tkzMarkRightAngle(D,F,B)
\tkzLabelPoints[below right](A,B,O,O',E,D)
\end{tikzpicture}
19.2.9 Circle defined by a center and a measure, and special cases

Let’s look at some special cases, such as straight lines tangent to the circle.

Compiled output

\begin{tikzpicture}[scale=.5]
\tkzDefPoint(0,8){A} \tkzDefPoint(8,0){B}
\tkzDefPoint(8,8){C} \tkzDefPoint(4,4){D}
\tkzDefPoint(2,4){E} \tkzDefPoint(4,2){F}
\tkzDefPoint(8,4){G}
\tkzInterLC(A,C)(D,G) \tkzGetPoints{I1}{I2}
\tkzInterLC(B,C)(D,G) \tkzGetPoints{J1}{J2}
\tkzInterLC[near](A,B)(D,G) \tkzGetPoints{K1}{K2}
\tkzInterLC(E,F)(D,G) \tkzGetPoints{E1}{E2}
\tkzDrawCircle(D,G)
\tkzDrawPoints[color=red](I1,J1,K1,K2,E1,E2)
\tkzDrawLines(A,B B,C A,C I2,J2 E1,E2)
\tkzDrawPoints[color=blue](A,...,F)
\tkzDrawPoints[color=red](I2,J2)
\tkzLabelPoints[left](B,D,E,F)
\tkzLabelPoints[below left](A,C)
\tkzLabelPoints[below=4pt](I1,K1,K2,E2)
\tkzLabelPoints[left](J1,E1)
\end{tikzpicture}
19.2.10 Calculation of radius

With pgfmath and \pgfmathsetmacro

The radius may be the result of a calculation, done before the intersection macro rather than inside it. A length can be calculated in several ways. You can of course use the module pgfmath and the macro \pgfmathsetmacro. In some cases the results are not precise enough: the calculation \(0.0002 \div 0.0001\) gives \(1.98\) with pgfmath, while xfp gives \(2\).

With xfp and \fpeval:

Compiled output

\begin{tikzpicture}
\tkzDefPoint(2,2){A}
\tkzDefPoint(5,4){B}
\tkzDefPoint(4,4){O}
\pgfmathsetmacro\tkzLen{\fpeval{0.0002/0.0001}}
% or \edef\tkzLen{\fpeval{0.0002/0.0001}}
\tkzInterLC[R](A,B)(O, \tkzLen)
\tkzGetPoints{I}{J}
\tkzDrawCircle(O,I)
\tkzDrawPoints[color=blue](A,B)
\tkzDrawPoints[color=red](I,J)
\tkzDrawLine(I,J)
\end{tikzpicture}
19.2.11 Option with nodes

Compiled output

\begin{tikzpicture}[scale=.75]
\tkzDefPoints{0/0/A,4/0/B,1/1/D,2/0/E}
\tkzDefTriangle[equilateral](A,B)
\tkzGetPoint{C}
\tkzInterLC[with nodes](D,E)(C,A,B)
\tkzGetPoints{F}{G}
\tkzDrawCircle(C,A)
\tkzDrawPolygon(A,B,C)
\tkzDrawPoints(A,...,G)
\tkzDrawLine(F,G)
\end{tikzpicture}
19.3 Intersection of two circles \tkzInterCC

The most frequent case is that of two circles defined by their center and a point, but as before the option R allows you to give the radius as a measure.

  • \tkzInterCC[⟨options⟩](⟨\(O,A\)⟩)(⟨\(O',A'\)⟩) or (⟨\(O,r\)⟩)(⟨\(O',r'\)⟩) or (⟨\(O,A,B\)⟩) (⟨\(O',C,D\)⟩)

  • optionsdefaultdefinition
    NN\(OA\) and \(O'A'\) are radii, \(O\) and \(O'\) are the centers.
    RN\(r\) and \(r'\) are dimensions and measure the radii.
    with nodesNin (A,A,C)(C,B,F) AC and BF give the radii.
    common=ptpt is common point; tkzFirstPoint gives the other point.

    This macro defines the intersection points \(I\) and \(J\) of the two circles with centers \(O\) and \(O'\). If the two circles have no common point, the macro ends with an error that is not handled. If the centers are \(O\) and \(O'\) and the intersections are \(A\) and \(B\), the angles \(\widehat{O,A,O'}\) and \(\widehat{O,B,O'}\) have opposite orientations; tkzFirstPoint is assigned to the point that forms the clockwise angle.

  • \tkzTestInterCC(⟨\(O,A\)⟩)(⟨\(O',B\)⟩)

  • The arguments are two pairs, which define two circles (each with a center and a point of the circle). If the two circles intersect, the test \iftkzFlagCC is true.

19.3.1 Testing a circle-circle intersection: \tkzTestInterCC

Compiled output

\begin{tikzpicture}[scale=.75]
\tkzDefPoints{% x y name
0 /0 /A,
2 /0 /B,
4 /0 /I,
1 /0 /P}
\tkzDrawCircle(A,B)
\foreach \i in {1,...,3}{%
\coordinate (P) at (\i,0);
\tkzDrawCircle[new](I,P)
\tkzTestInterCC(A,B)(I,P)
\iftkzFlagCC
\tkzInterCC(A,B)(I,P) \tkzGetPoints{a}{b}
\tkzDrawPoints(a,b)
\fi}
\end{tikzpicture}
19.3.2 Circle-circle intersection with a common point

Compiled output

\begin{tikzpicture}[scale=.5]
\tkzDefPoints{0/0/O,5/-1/A,2/2/B}
\tkzDrawPoints(O,A,B)
\tkzDrawCircles(O,B A,B)
\tkzInterCC[common=B](O,B)(A,B)
\tkzGetFirstPoint{C}
\tkzDrawPoint(C)
\tkzLabelPoints[above](O,A,B,C)
\end{tikzpicture}
19.3.3 Circle-circle intersection: order of the points

The idea is to compare the angles formed by the first center, a resulting point and the center of the second circle. The first point is the one that gives the smallest angle.

As you can see, \(\widehat{ODB} < \widehat{OBE}\).

Compiled output

\begin{tikzpicture}[scale=.5]
\pgfkeys{/pgf/number format/.cd,fixed relative,
precision=4}
\tkzDefPoints{0/0/O,5/-1/A,2/2/B,2/-1/C}
\tkzDrawPoints(O,A,B)
\tkzDrawCircles(O,A B,C)
\tkzInterCC(O,A)(B,C)\tkzGetPoints{D}{E}
\tkzDrawPoints(C,D,E)
\tkzLabelPoints(O,A,B,C)
\tkzLabelPoints[above](D,E)
\tkzDrawSegments[cyan](D,O D,B)
\tkzMarkAngle[red,->,size=1.5](O,D,B)
\tkzFindAngle(O,D,B) \tkzGetAngle{an}
\tkzLabelAngle(O,D,B){$ \pgfmathprintnumber{\an}$}
\tkzDrawSegments[cyan](E,O E,B)
\tkzMarkAngle[red,->,size=1.5](O,E,B)
\tkzFindAngle(O,E,B) \tkzGetAngle{an}
\tkzLabelAngle(O,E,B){$ \pgfmathprintnumber{\an}$}
\end{tikzpicture}
19.3.4 Construction of an equilateral triangle

\(\widehat{A,C,B}\) is a clockwise angle.

Compiled output

\begin{tikzpicture}[trim left=-1cm,scale=.5]
\tkzDefPoint(1,1){A}
\tkzDefPoint(5,1){B}
\tkzInterCC(A,B)(B,A)\tkzGetPoints{C}{D}
\tkzDrawPoint[color=black](C)
\tkzDrawCircles(A,B B,A)
\tkzCompass[color=red](A,C)
\tkzCompass[color=red](B,C)
\tkzDrawPolygon(A,B,C)
\tkzMarkSegments[mark=s|](A,C B,C)
\tkzLabelPoints[](A,B)
\tkzLabelPoint[above](C){$C$}
\end{tikzpicture}
19.3.5 Segment trisection

The idea here is to divide a segment into three equal parts with a ruler and a compass.

Compiled output

\begin{tikzpicture}[scale=.6]
\tkzDefPoint(0,0){A}
\tkzDefPoint(3,2){B}
\tkzInterCC(A,B)(B,A) \tkzGetSecondPoint{D}
\tkzInterCC(D,B)(B,A) \tkzGetPoints{A}{C}
\tkzInterCC(D,B)(A,B) \tkzGetPoints{E}{B}
\tkzInterLC[common=D](C,D)(E,D)\tkzGetFirstPoint{F}
\tkzInterLL(A,F)(B,C) \tkzGetPoint{O}
\tkzInterLL(O,D)(A,B) \tkzGetPoint{H}
\tkzInterLL(O,E)(A,B) \tkzGetPoint{G}
\tkzDrawCircles(D,E A,B B,A E,A)
\tkzDrawSegments[](O,F O,B O,D O,E)
\tkzDrawPoints(A,...,H)
\tkzDrawSegments(A,B B,D A,D A,E E,F C,F B,C)
\tkzMarkSegments[mark=s|](A,G G,H H,B)
\end{tikzpicture}
19.3.6 With the option with nodes

Compiled output

\begin{tikzpicture}[scale=.5]
\tkzDefPoints{0/0/A,0/5/B,5/0/C}
\tkzDefPoint(54:5){F}
\tkzInterCC[with nodes](A,A,C)(C,B,F)
\tkzGetPoints{a}{e}
\tkzInterCC(A,C)(a,e) \tkzGetFirstPoint{b}
\tkzInterCC(A,C)(b,a) \tkzGetFirstPoint{c}
\tkzInterCC(A,C)(c,b) \tkzGetFirstPoint{d}
\tkzDrawCircle[new](A,C)
\tkzDrawPoints(a,b,c,d,e)
\tkzDrawPolygon(a,b,c,d,e)
\foreach \vertex/\num in {a/36,b/108,c/180,
d/252,e/324}{%
\tkzDrawPoint(\vertex)
\tkzLabelPoint[label=\num:$\vertex$](\vertex){}
\tkzDrawSegment(A,\vertex)
}
\end{tikzpicture}
19.3.7 Mix of intersections

Compiled output

\begin{tikzpicture}[scale = .7]
\tkzDefPoint(2,2){A}
\tkzDefPoint(0,0){B}
\tkzDefPoint(-2,2){C}
\tkzDefPoint(0,4){D}
\tkzDefPoint(4,2){E}
\tkzCircumCenter(A,B,C)\tkzGetPoint{O}
\tkzInterCC[R](O,2)(D,2)\tkzGetPoints{M1}{M2}
\tkzInterCC(O,A)(D,O) \tkzGetPoints{1}{2}
\tkzInterLC(A,E)(B,M1)\tkzGetSecondPoint{M3}
\tkzInterLC(O,C)(M3,D)\tkzGetSecondPoint{L}
\tkzDrawSegments(C,L)
\tkzDrawPoints(A,B,C,D,E,M1,M2,M3,O,L)
\tkzDrawSegments(O,E)
\tkzDrawSegments[new](C,A D,B)
\tkzDrawPoint(O)
\tkzDrawCircles[new](M3,D B,M2 D,O)
\tkzDrawCircle(O,A)
\tkzLabelPoints[below right](A,B,C,D,E,M1,M2,M3,O,L)
\end{tikzpicture}
19.3.8 Altshiller-Court’s theorem

The two lines joining the points of intersection of two orthogonal circles to a point of one of the circles meet the other circle in two diametrically opposite points (Altshiller-Court, p. 176).

Compiled output

\begin{tikzpicture}
\tkzDefPoints{0/0/P,5/0/Q,3/2/I}
\tkzDefCircle[orthogonal from=P](Q,I)
\tkzGetFirstPoint{E}
\tkzDrawCircles(P,E Q,E)
\tkzInterCC[common=E](P,E)(Q,E) \tkzGetFirstPoint{F}
\tkzDefPointOnCircle[through = center P angle 80 point E]
\tkzGetPoint{A}
\tkzInterLC[common=E](A,E)(Q,E) \tkzGetFirstPoint{C}
\tkzInterLL(A,F)(C,Q) \tkzGetPoint{D}
\tkzDrawLines[add=0 and 1](P,Q)
\tkzDrawLines[add=0 and 2](A,E)
\tkzDrawSegments(P,E E,F F,C A,F C,D)
\tkzDrawPoints(P,Q,E,F,A,C,D)
\tkzLabelPoints(P,Q,F)
\tkzLabelPoints[above](E,A)
\tkzLabelPoints[left](D)
\tkzLabelPoints[above right](C)
\end{tikzpicture}