# Drawing Three Tangential Lines on a TikZ Diagram to a Specific Point on a Circle's Circumference

How to draw the three red lines shown in the TikZ picture below:

• Line 1: Start from the inner circle's circumference at 0 degrees, extending tangentially to the north, and reach the middle circle. Position the number '20' along the midway point of this line.

• Line 2: Initiate from the middle circle's circumference at 180 degrees, extending tangentially to the south, and connect to the middle circle. Position the number '21' along the midway point of this line.

• Line 3: Begin from the inner circle's circumference at 270 degrees, extending tangentially to the east, and reach the outer circle. Place the letter 'x' at the midway point of this line.

Look at the drawing below for illustration.

CODE:

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}

\draw (0,0) circle (1);
\draw (0,0) circle (2);
\draw (0,0) circle (2.7);

\end{tikzpicture}

\end{document}


OUTPUT (red lines and characters added only for clarification):

FINAL WORK (Thanks to the community):

• You can use polar coordinate like (-90: 1) for one end. The intersections library might be the easiest way to find the other ends. Or use trig and calculate the length needed. Nov 30, 2023 at 20:48
• This is basically a trigonometry question which you like to be solved with TikZ methods? (Positioning a number along a line won't be a problem. That's a core functionality of TikZ.) Nov 30, 2023 at 20:57
• Math problem from Spiegel online a couple of days ago? :-) Dec 1, 2023 at 15:09
• Yes thats a Spiegel online Problem Dec 1, 2023 at 15:31

As was already mentioned in the comments, this is essentially just a practical example of the Pythagorean theorem (note that I shifted the labels so that they are not cut by the circles, but the $x$ shows how to position a label midway using midway):

\documentclass[border=10pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\draw[red, densely dotted] (3,0) -- (-3,0);
\draw[red, densely dotted] (0,3) -- (0,-3);

% a^2 + b^2 = c^2 <=> b = (c^2 - a^2)^0.5

\draw[red, thick] (1,0) -- (1,{sqrt(2*2-1*1)})
node[pos=0.75, left] {20};

\draw[red, thick] (0,-1) -- ({sqrt(2.7*2.7-1*1)},-1)
node[pos=0.5, above] {$x$};

\draw[red, thick] (-2,0) -- (-2,{-1*sqrt(2.7*2.7-2*2)})
node[pos=0.25, left] {21};

\end{tikzpicture}
\end{document}


Graphical explanation:

\documentclass[border=10pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\begin{scope}[opacity=0.25]

\draw[red, densely dotted] (3,0) -- (-3,0);
\draw[red, densely dotted] (0,3) -- (0,-3);

\draw[red, thick] (1,0) -- (1,{sqrt(2*2-1*1)})
node[pos=0.75, left] {20};

\draw[red, thick] (0,-1) -- ({sqrt(2.7*2.7-1*1)},-1)
node[pos=0.5, above] {$x$};

\draw[red, thick] (-2,0) -- (-2,{-1*sqrt(2.7*2.7-2*2)})
node[pos=0.25, left] {21};
\end{scope}

\draw[red] (-2,{-1*sqrt(2.7*2.7-2*2)})
|- node[pos=0.25, left] {$b = \sqrt{c^{2} - a^{2}}$}
node[pos=0.75, above] {$a = 2$} (0,0)
-- node[below right] {$c = 2.7$} cycle;
\draw[red, very thin] (-2,-0.25) -| (-1.75,0);

\end{tikzpicture}
\end{document}


Bonus: The very same drawing using the l3draw package (positioning of the labels might be a tad different):

\documentclass[border=10pt]{standalone}
\usepackage{l3draw}

\begin{document}
\ExplSyntaxOn
\draw_begin:

\draw_path_circle:nn { 0cm , 0cm } { 1cm }
\draw_path_circle:nn { 0cm , 0cm } { 2cm }
\draw_path_circle:nn { 0cm , 0cm } { 2.7cm }
\draw_path_use_clear:n { stroke }

\color_select:n { red }
\draw_scope_begin:
\draw_dash_pattern:nn { 1pt } { 0cm }
\draw_path_moveto:n { 3cm , 0cm }
\draw_path_lineto:n { -3cm , 0cm }
\draw_path_moveto:n { 0cm , 3cm }
\draw_path_lineto:n { 0cm , -3cm }
\draw_path_use_clear:n { stroke }
\draw_scope_end:

\draw_linewidth:n { 0.8pt }
\draw_path_moveto:n { 1cm , 0cm }
\draw_path_lineto:n { 1cm , sqrt(2^2 - 1^2) * 1cm }
\draw_path_use_clear:n { stroke }

\draw_scope_begin:
\hcoffin_set:Nn \l_tmpa_coffin { 20 }
\draw_transform_shift:n { 0.9cm , sqrt(2^2 - 1^2) * 0.75cm }
\draw_coffin_use:Nnn \l_tmpa_coffin { r } { vc }
\draw_scope_end:

\draw_path_moveto:n { 0cm , -1cm }
\draw_path_lineto:n { sqrt(2.7^2 - 1^2) * 1cm , -1cm }
\draw_path_use_clear:n { stroke }

\draw_scope_begin:
\hcoffin_set:Nn \l_tmpa_coffin { $x$ }
\draw_transform_shift:n { sqrt(2.7^2 - 1^2) * 0.5cm , -0.9cm }
\draw_coffin_use:Nnn \l_tmpa_coffin { hc } { b }
\draw_scope_end:

\draw_path_moveto:n { -2cm , 0cm }
\draw_path_lineto:n { -2cm , sqrt(2.7^2 - 2^2) * -1cm }
\draw_path_use_clear:n { stroke }

\draw_scope_begin:
\hcoffin_set:Nn \l_tmpa_coffin { 21 }
\draw_transform_shift:n { -2.1cm , sqrt(2.7^2 - 2^2) * -0.25cm }
\draw_coffin_use:Nnn \l_tmpa_coffin { r } { vc }
\draw_scope_end:

\draw_end:
\ExplSyntaxOff
\end{document}


• Chapeau Jasper! I have the same solution...later.(+1) Nov 30, 2023 at 21:26
• @MarcoMoldenhauer You're welcome. I added a graphical explanation even. Note that I used 2.7*2.7 in the code instead of 2.7^2 which would also work, but TeX is better with multiplication than with calculating powers. Of course, I also wrote 1*1 to make things clear. Nov 30, 2023 at 21:26
• The \fp_eval:n shouldn't be necessary. Much like PGF, l3draw seems to throw everything into evaluation as well. Dec 1, 2023 at 15:12
• @Qrrbrbirlbel True! Thanks for pointing this out! I proposed that some easier command be defined to position coffins in a drawing. It seems that they are always positioned at the origin. It also seems that \coffin_typeset:Nnnnn can be used, but it has a different syntax. Or do you know of some simpler way than my approach? Dec 1, 2023 at 15:31

Here's a solution where the underlying driver (here PDF) does the math for you by clipping the colored lines against the circles.

The order of the paths are so that the colored lines all are behind the circles. Of course, this way, the nodes' placement needs to be guesstimated a bit but it's very simple here.

If you need arrow tips at the points where the straight lines touch the circles or need to draw another line to it math will have to get involved (either by you or by TikZ).

## Code

\documentclass[tikz]{standalone}
\begin{document}
\tikz
\draw[every edge/.append style={densely dotted, red}]
(left:3) edge (right:3)
(down:3) edge (up:3)
[path picture={
\draw[green] (left:2) -- node[near start,left] {$21$} +(down:2.7);
\draw[red] (down:1) -- node[above] {$x$} +(right:2.7);
[path picture={
\draw[blue] (right:1) -- node[right] {$20$} +(up:2);
}];
}];
\end{document}


## Output

• Thanks for your Solution. Dec 1, 2023 at 16:49
% !TEX TS-program = lualatex
\documentclass{standalone}
\usepackage{tkz-euclide,tkz-elements}
\begin{document}

\begin{tkzelements}
function pytha (a,b)
return math.sqrt(a*a-b*b)
end

ra,rb,rc = 1,2,2.7
z.O = point : new ( 0  , 0  )
z.A = point : new ( ra , 0  )
z.B = point : new ( 0  , -ra  )
z.C = point : new ( -rb  , 0 )
z.D = point : new ( rc , 0  )
z.Ap = z.A : north (pytha(rb,ra))
z.Bp = z.B : east  (pytha(rc,ra))
z.Cp = z.C : south (pytha(rc,rb))
\end{tkzelements}

\begin{tikzpicture}
\tkzGetNodes
\tkzDrawCircles(O,A O,C O,D)
\tkzDrawSegments[red,thick](A,A' B,B' C,C')
\tkzLabelSegment[red,above](B,B'){$x$}
\tkzLabelSegment[red,right](A,A'){$20$}
\tkzLabelSegment[red,left](C,C') {$21$}
\draw[red, densely dotted] (3,0) -- (-3,0)
(0,3) -- (0,-3);
\end{tikzpicture}
\end{document}


• thanks Alain for your effort. nice Work. Dec 1, 2023 at 16:48