# Issue with trigonometric ratios in \foreach statement

I have tried executing the following snippet of code, but it keeps failing with "Package pgf Error: No shape named -O is known }"

    \foreach \x in {180,185,...,360} {
% lines from center to point
\draw[dotted,->-=0.8,gray] (0cm,0cm) -- (\x:1cm);
\draw[] (-0.5cm*sin(270-\x),-0.5cm*cos(270-\x)) -- (-0.5cm*sin(270-\x),-0.7cm*cos(270-\x));
% dots at each point
\filldraw[black] (\x:1cm) circle(0.4pt);

}


Is it that you cannot compute these ratios with angles in degrees like I am trying to above, but only when they are expressed in radians?

Is this possibly what you want to achieve?

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\foreach \x in {180,185,...,360} {
\pgfmathsetmacro\A{-0.5*sin(270-\x)}
\pgfmathsetmacro\B{-0.5*cos(270-\x)}
\pgfmathsetmacro\C{-0.7*cos(270-\x)}
% lines from center to point
\draw[dotted,->=0.8,gray] (0cm,0cm) -- (\x:1cm);
\draw[] (\A,\B) -- (\A,\C);
% dots at each point
\filldraw[black] (\x:1cm) circle(0.4pt);
}
\end{tikzpicture}

\end{document}


• @stars83clouds You might do computations also in the coordinates with \$, but it would be more inefficient. – egreg Oct 19 '17 at 17:25
• Yes @egreg, this is close to what I am trying to produce. However, the horizontal components are not joined to the vertical ones. Also, is it not plausible to have the trigonometric ratios computed within the \foreach statement, so as to make the code more portable? – stars83clouds Oct 19 '17 at 17:30
• Forget the last comment, it doesn't apply here. – stars83clouds Oct 19 '17 at 20:07