# how can I draw the radius of an arc using r * (cos (angle) and sin (angle))

i want to draw an arc of circle, and figure out the raduis on the graph, using:

when i specify the radius r=1.5cm, i can't get it on the border, anyone can help me, thanks in advance

\documentclass[border=30pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, calc, decorations.markings, quotes}
\begin{document}
\begin{tikzpicture}
\draw[thick, violet] (0,0) -- (4,0);
\node[left] at (0,0){$O$};
\node[right] at (4,0){$O'$};
\fill[red] (2,0) circle (1.1pt);
\draw[thick, red] (2,0) -- ({1.5*cos(40)},{1.5*sin(40)});
\draw (3.5,0) arc (0:180:1.5) ;\node[above] at (2.5,0){$O$};
\end{tikzpicture}
\end{document}


Add ++.

\documentclass[border=30pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, calc, decorations.markings, quotes}
\begin{document}
\begin{tikzpicture}
\draw[thick, violet] (0,0) -- (4,0);
\node[left] at (0,0){$O$};
\node[right] at (4,0){$O'$};
\fill[red] (2,0) circle (1.1pt);
\draw[thick, red] (2,0) -- ++({1.5*cos(40)},{1.5*sin(40)});
\draw (3.5,0) arc (0:180:1.5) ;\node[above] at (2.5,0){$O$};
\end{tikzpicture}
\end{document}


• thank you for your answers which are very fast and very useful – moradov Mar 26 '18 at 15:39
• In place of ({1.5*cos(40)},{1.5*sin(40)}) you should probably use (40:1.5), and you can add only one + here ;) – Kpym Mar 26 '18 at 16:51
• @Kpym I agree with all these statements, but the reason why the original code didn't work was that at least one + was missing. – user121799 Mar 26 '18 at 16:57

For calculations, you can use the \tikzmath command in tikz. This requires you to load the appropriate library:

\usepackage{tikz}
\usetikzlibrary{math}


You then define define variables inside the \tikzmath command and use these variables as coordinates, e.g.:

\begin{tikzpicture}
\tikzmath{
\angle = 40;
\coordX = 1.5 * cos(\angle);
\coordY = 1.5 * sin(\angle);
}
\draw[thick, red] (2,0) -- ++(\coordX,\coordY);
\end{tikzpicture}


I'm not quite sure if this will work since I've only used \tikzmath once so far. Hope this helps and doesn't contain too many mistakes (code is untested, math library apparently not necessary...see comment below).

• looks like someone beat me to it =) – Jay_At_Play Mar 26 '18 at 15:45
• You should add + or ++ to obtain the radius of the arc as asked in the question. And you don't need math library for this. – Kpym Mar 26 '18 at 16:57
• Thanks for the feedback @Kpym. Had to google what ++ does (answer is here), learnt something new, and edited my post. Thank you =). – Jay_At_Play Mar 27 '18 at 6:51