Example: Sine and Cosine functions animation

Published 2009-10-26 | Author: Efraín Soto Apolinar

This animation helps explain the geometric interpretation of the sine and cosine functions.

Download as: [PDF] [TEX]  •  [Open in Overleaf]

Sine and Cosine functions animation

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% Sine and Cosine functions animation
%
% Author:
% Efraín Soto Apolinar.
% http://www.aprendematematicas.org/
% 
% This animation helps explain the 
% geometric interpretation of the 
% sine and cosine functions.
%

\documentclass[spanish,10pt]{beamer}
\usepackage[ansinew]{inputenc} % Language = Spanish
%
\usepackage{color}
\usepackage{tikz}
\usepackage{hyperref}
\hypersetup{pdfpagemode=FullScreen}
\usepackage{ifthen}
\usepackage{animate}
%
\usetheme{Warsaw} 
\usecolortheme{whale}
%
%
%
\newcounter{angle}
\setcounter{angle}{0}
%
\begin{document}
%
%
%
\begin{frame}[fragile]{Sine and Cosine functions}
\begin{center}
\begin{animateinline}[loop, poster = first, controls]{30}
%
\whiledo{\theangle<359}{
%
    \begin{tikzpicture}
    % Axis
    \draw[thick,->,blue] (-3,0)--(3,0) node[below] {$x$}; % x axis
    \draw[thick,->,blue] (0,-3)--(0,3) node[left] {$y$}; % y axis
    \draw[red,thick] (0,0) circle (2.5cm);
    \node[red,below] at (2.6,0) {1};
    \node[red,above] at (0.1,-2.5) {1};
    %
    \draw[ultra thick,cyan] (0,0) -- (0,0 |- \theangle:2.5cm); % UpOn x axis
    \draw[ultra thick,orange] (0,0) -- (\theangle:2.5cm |- 0,0); % UpOn y axis
    %
    \draw[densely dotted,orange] (\theangle:2.5cm) -- (\theangle:2.5cm |- 0,0); % vertical line
    \draw[densely dotted,cyan] (\theangle:2.5cm) -- (0,0 |- \theangle:2.5cm); % horizontal line
    \draw[ultra thick,red,->,rotate=\theangle] (0,0) -- (2.5,0); 
    \node[red,orange,right] at (0,-3.5) 
            {\footnotesize$\cos(\theangle^{\mathrm{o}}) = \pgfmathcos{\theangle}\pgfmathresult$};
    \node[red,cyan,right] at (0,-3.1) 
            {\footnotesize$\sin(\theangle^{\mathrm{o}}) = \pgfmathsin{\theangle}\pgfmathresult$};
    \end{tikzpicture}
    %
    \stepcounter{angle}
    \ifthenelse{\theangle<359}{
            \newframe
    }{
            \end{animateinline}
    }
}
\end{center}
\end{frame}
%
%
%
\end{document}

Comments

  • #1 Kjell Magne Fauske, October 26, 2009 at 2:05 p.m.

    Adobe Acrobat is required to view the animation.

  • #2 Peter, November 17, 2009 at 3:20 p.m.

    You can view the animation also in Foxit Reader, but only in windows version. :(

  • #3 Alexander, November 27, 2009 at 2:55 p.m.

    Slightly improved version can be downloaded here. Again, whiledo has been replaced by the simpler to be used multiframe command:

    ftp://ftp.fzd.de/private/grahn/sine-and-cosine-functions-animation.tex

    ftp://ftp.fzd.de/private/grahn/sine-and-cosine-functions-animation.pdf

  • #4 Manuel, May 7, 2010 at 4:46 p.m.

    ftp://ftp.fzd.de/private/grahn/sine-and-cosine-functions-animation.pdf

    The link is dead?!

  • #5 Patrick, June 3, 2010 at 9:57 p.m.

    I must admit the only command I don't like to use yet with TiKz is the whiledo, in which the logic isn't quite as clear as other TiKz commands.

    The link does seem to be dead, so it would be great to take a look at this multiframe command you mentioned by getting a new link.

Adding comments is currently not enabled.