# Draw an arc using radius and angles up to specific point

I have following code in TiKZ:

\documentclass[border=.5cm]{standalone}

\usepackage{tikz}

\usetikzlibrary{positioning,calc,decorations.text}

\begin{document}
\begin{tikzpicture}

\draw (0, 0) circle (1cm);

\draw[rounded corners = .1cm] (200:1.2cm) arc (200:-20:1.2cm) -- (-20:2.2cm) arc (-20:200:2.2cm) -- cycle;
\draw[] (0,1.25cm) -- (0,2.15cm);

\draw[gray] (-.1cm,2.3cm) -- (-.1cm,3.5cm);
\draw[gray] (200:2.4cm) arc (200:90:2.4cm);
\draw[gray] (90:3.4cm) arc (90:200:3.4cm);

\draw[rounded corners = .1cm, red] (200:2.4cm) arc (200:90:2.4cm) -- (90:3.4cm) arc (90:200:3.4cm) -- cycle;

\end{tikzpicture}
\end{document}


Which result in the following picture:

But I need a slightly different image. I need red figure to follow gray vertical line (not at 90 degrees).

Any suggestions will highly appreciate.

• You need to change start/end angle of red line accordingly. Both angle you can calculate from geometry relations of this line to circle origin. – Zarko Jun 30 '16 at 18:21
• Maybe this can help to draw arcs to a specific point: Q71548. Note, that you have to switch the arguments of atan2 nowadays. – Qrrbrbirlbel Jun 30 '16 at 18:44
• do you mean as a simple rotation? – percusse Jun 30 '16 at 19:59
• @percusse not rotation. I need figure edge to follow gray line (e.g. be little bit shorter) – bronislav Jun 30 '16 at 20:26

Is this what you want? I use \pgfgetlastxy to get the x and y coordinates of the intersection points. Then I use pgfmath package to compute the polar angle of the intersection points.

\documentclass[border=.5cm]{standalone}

\usepackage{pgfmath,tikz}

\usetikzlibrary{intersections}

\begin{document}
\begin{tikzpicture}

\draw (0, 0) circle (1cm);

\draw[rounded corners = .1cm] (200:1.2cm) arc (200:-20:1.2cm) -- (-20:2.2cm) arc (-20:200:2.2cm) -- cycle;
\draw[] (0,1.25cm) -- (0,2.15cm);

\draw[gray,name path=ver] (-.1cm,2.3cm) -- (-.1cm,3.5cm);
\draw[gray,name path=bot] (200:2.4cm) arc (200:90:2.4cm);
\draw[gray,name path=top] (90:3.4cm) arc (90:200:3.4cm);
\path[name intersections={of=top and ver,by=T}];
\path[name intersections={of=bot and ver,by=B}];
\path (T);\pgfgetlastxy{\XT}{\YT};
\path (B);\pgfgetlastxy{\XB}{\YB};
\pgfmathparse{atan2(\YT,\XT)}
\edef\topangle{\pgfmathresult}
\pgfmathparse{atan2(\YB,\XB)}
\edef\botangle{\pgfmathresult}

\draw[thick,rounded corners = .1cm, red]
(200:2.4cm) arc (200:\botangle:2.4cm) -- (\topangle:3.4cm) arc (\topangle:200:3.4cm) -- cycle;

\end{tikzpicture}
\end{document}