# Using the commands \pgfmathparse and \pgfmathresult

How do I use the commands \pgfmathparse {tan (pi/3 r)} \pgfmathresult to draw the green line in the figure below?

\begin{tikzpicture}[>=latex,scale=2]
\draw circle (1);
\draw[->] (-1.2,0) -- (1.2,0) coordinate (x);
\draw[->] (0,-1.2) -- (0,1.2);

\fill[fill=green!25] (0,0) -- (.2,0) arc (0:60:.2) -- cycle;
\draw (0,0) -- (60:1);
\draw[<-,red,line width=1pt] (60:1) -- (60:1 |- x);
\draw (0,0) -- (60:2);
%tangent
\draw[<-,green,line width=1pt] (60:2) -- (1,0);
\end{tikzpicture}


-

Not exactly sure what you are asking or what is wrong with what you have, but here is how I would do it: Use \pgfmathsetmacro which invokes \pgfmathparse and uses the result from \pgfmathresult.

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[>=latex,scale=2]
\draw circle (1);
\draw[->] (-1.2,0) -- (1.2,0) coordinate (x);
\draw[->] (0,-1.2) -- (0,1.2);

\fill[fill=green!25] (0,0) -- (.2,0) arc (0:60:.2) -- cycle;
\draw[<-,red,line width=1pt] (60:1) -- (60:1 |- x);
\draw (0,0) -- (60:2);
%tangent
%\draw[<-,green,line width=1pt] (60:2) -- (1,0);
\draw[<-,green,line width=1pt] (1,\YValue) -- (1,0);
\end{tikzpicture}
\end{document}


I also removed the redundant \draw (0,0) -- (60:1); as that line gets overwritten by \draw (0,0) -- (60:2);.

-
Thanks Peter Grill. –  Regis da Silva Sep 12 '11 at 3:13