Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can I improve this code to generate three cycles varying the height of the trigonometric tangent? Note that I managed to correctly draw the red line, but could not improve the green line. What I want is a reduction in their angle and straight. The green line does not have the correct height.

\begin{tikzpicture}[>=latex,scale=2]
\foreach \radius in {1,2,3}{
    \pgfmathsetmacro{\YValue}{tan(60/\radius)*\radius}
    \pgfmathsetmacro{\sinus}{sin(60/\radius)*\radius}
    \pgfmathsetmacro{\cosinus}{cos(60/\radius)*\radius}
    \begin{scope}[xshift=3*\radius cm]
        \draw circle (1);
        %axis
        \draw[->] (-1.2,0) -- (1.2,0) coordinate (x);
        \draw[->] (0,-1.2) -- (0,1.2);
        %angles
        \fill[fill=green!25] (0,0) -- (.2,0) arc (0:60/\radius:.2) -- cycle;
        %sinus
        \coordinate (P) at (60/\radius:1);
        \draw[<-,red,line width=1pt] (P) -- (P |- x);
        \fill[blue] (P) circle (1pt);
        \draw (0,0) -- (P);
        %cosinus
        \draw[->,orange] (0,0) -- (P |- 0,0);
        %tangent
        \draw[dashed] (0,0) -- (1,\YValue);
        \draw[->,green,line width=1pt] (1,0) -- (1,\YValue);
    \end{scope}
};
\end{tikzpicture}

enter image description here

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

If I understand correctly, the green line is the tangent of the green angle. Then you should rewrite the formulae in the \foreach loop like this:

    \pgfmathsetmacro{\YValue}{tan(60/\radius)}
    \pgfmathsetmacro{\sinus}{sin(60/\radius)}
    \pgfmathsetmacro{\cosinus}{cos(60/\radius)}

enter image description here

share|improve this answer
    
Thank you Count Zero. –  Regis da Silva Sep 13 '11 at 15:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.