I am trying to execute the following code where I compute the coordinates using the TikZ math
library and then I draw them in TikZ.
Why does it output error ! Package pgf Error: No shape named '2*cos(60' is known.
when defining the coordinate with mathematical functions (in my case with sin
and cos
)?
The pgf math functions should be readily available in the TikZ math library.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{math}
\begin{document}
\begin{tikzpicture}
\tikzmath{
coordinate \x;
\x1=(0,0);
\x2=(1.5,0);
\x3 = (2*cos(60), 2*sin(60));
}
\draw[help lines] (0,0) grid (2,2);
\draw[->] (-0.2,0) -- (2.2,0) node [anchor=west] {$x$};
\draw[->] (0,-0.2) -- (0,2.2) node [anchor=south] {$y$};
\draw [red,thick] (\x1) -- (\x2) -- (\x3) -- cycle;
\end{tikzpicture}
\end{document}
Expected drawing
)
of the coordinate and the parenthesis of the function interfere.