Possible Duplicate:
Problems with TikZ calculations

I am trying to get the following arrows to get lengths defined by a trigonometric function, in this case cos. This was my attempt, but it does not yield any results:

    \foreach \y in {1,0.8,...,0}
    \path (1,\y) edge[->] ++(2-cos(\y*pi/2),0)(1,-\y) edge[->] ++(2-cos(\y*pi/2),0);

The errors I get are both from tikz/pgf: "no shape named 2-cos(0 is known." and "Giving up on this path, did you forget a semicolon?"

  • I strongly suspect that this is related to the problem at this question: tex.stackexchange.com/q/31830/86 where TikZ gets confused by the parentheses. Take a look at the answers to that and see if they help. If so, we'll probably close this as a duplicate of that to keep the place tidy. If not, please edit your question to explain why that doesn't help. Oct 19, 2011 at 8:57
  • 1
    Indeed this is a duplicate IMHO. You need to mask the inner set of ( ) using { }. Also please always state the exact error you get, "does not yield any results" doesn't tell other people much. Thanks. Oct 19, 2011 at 9:10
  • I'm closing this as a duplicate now to avoid repetition on this site. In your case use: \path (1,\y) edge[->] ++({2-cos(\y*pi/2)},0) (1,-\y) edge[->] ++({2-cos(\y*pi/2)},0); to make it work. Oct 19, 2011 at 9:12


Browse other questions tagged or ask your own question.