# How to animate a sine curve in PStricks/Tikz

I would like to know how to set up an animations which consists of two "sub-animations" side by side or above/below, wherein one animation just shows a real number line from say zero to 2 pi one and the number line is coloured in as we move from zero to one. Simultaneously, the other animation will show the plot of sine(number) where the number is as far as we are on the number line. Hence at the end of the animation the plot of a full period of a sine wave will be shown.

• – Ignasi Oct 13 '14 at 15:21

I have no idea where yoiu really want to print the value of the sin curve. However, here is an example:

\documentclass[border=10pt]{standalone}
\usepackage{animate}
\usepackage{multido}
\def\TINY{\fontsize{2pt}{2.1pt}\selectfont}
\begin{document}
%-------------------- write timeline file ---------------------%
\newwrite\TimeLineFile
\immediate\openout\TimeLineFile=sinus.txt
\immediate\write\TimeLineFile{::0x0,1}%
\multido{\i=1+1}{37}{\immediate\write\TimeLineFile{::\i}}
\immediate\closeout\TimeLineFile
%------------------- assemble animation -----------------------%
\begin{animateinline}[controls,timeline=sinus.txt,
begin={\begin{pspicture}(-2,-1.5)(6.6,2)},
end={\end{pspicture}}]{3}
%---- static material: axes, labels, curve ----%
\psaxes[trigLabels,trigLabelBase=3]{->}(0,0)(-2mm,-1.5)(6.5,1.5)[t,-90][$y=\sin(t)$,0]
\psplot[xunit=1cm,linestyle=dashed,algebraic]{0}{\psPiTwo}{sin(x)}
\newframe
\multiframe{37}{r=0+0.174444,i=0+1}{\psset{xunit=1cm,linecolor=red}
\pscustom[xunit=1cm,fillcolor=red!30,fillstyle=solid,
linestyle=none,algebraic,dimen=inner]{%
\psplot{0}{\r}{sin(x)}
\psline(!\r\space 0)
}
\psplot[xunit=1cm,linestyle=dashed,linecolor=black,
algebraic]{0}{\r}{sin(x)}