all.
I'm trying to draw an incircle to a regular pentagon. Here's my code:
\documentclass[tikz,border=1.5mm]{standalone}
\usetikzlibrary{calc, math}
\begin{document}
\begin{tikzpicture}[rotate=90]
\pgfmathsetmacro{\R}{2}
\node[draw, circle, fill=black, thick, inner sep=0pt, outer sep=0pt] (0,0) (O) {};
%\draw (O) circle (\R);
\draw[fill=blue!10!white] %
(0:\R) %node[fill=black, thick, inner sep=1pt, outer sep=1pt] {}
\foreach \x in {72,144,...,360} {
-- (\x:\R)
}
-- cycle;% (90:\R);
\foreach \x in {0,72, 144, ..., 360} {
\draw[thick, densely dashed, %rotate=90
] (O) -- (\x:\R);
}
\draw[dotted] (O) -- (180:{0.8*\R}) node[label={below:$l$}] (B) {};
\node[anchor=north west] at (180:{0.4*\R}) {$a$};
\node[anchor=south] at (216:{0.6*\R}) {$r$};
\coordinate (c) at (B);
\draw[%rotate around={72:(c)}
] ($ (c) + (0.15,-0.01) $) -- ($ (c) + (0.15,0.15) $) -- ($ (c) + (0,0.15) $);
\pgfmathsetmacro{\ap}{cos(pi/5)*\R}
\draw[thin, densely dotted] (O) circle (\ap);
\end{tikzpicture}
\end{document}
The whole problem lies in the last two lines. The computation cos(pi/5)*\R
should give around 1.618, but when drawing a circle with that radius it gives the radius of the circumcircle (see attached picture). Perhaps I have a syntax error in using the PGF math
library, but I cannot see it. Naturally, when I manually input 1.618 into the radius, it draws what I want.
Thanks!