lundi 8 septembre 2014

Ballet de pendules : l'animation seulement

Le listing du fichier source :

\documentclass[11pt]{article}
 \usepackage[a4paper,margin=2cm]{geometry}
\usepackage[latin1]{inputenc}%
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{animate}
\usepackage{pst-plot,pst-node,pst-tools}
\title{Ballet de pendules}
\date{08 septembre 2014}
\newcommand\Bille{
\pscircle[fillstyle=solid,linewidth=1.5\pslinewidth,fillcolor=macouleur](0,0){0.75}
\psarc(0,0){0.6}{-110}{90}
\psarc(0,0){0.45}{-90}{70}
\psarc(0,0){0.3}{-70}{60}}%
\newcommand\Pendule{
\psline(C)
\rput{!TabAlphan \i\space get}(C){\Bille}}%
\psset{dimen=middle}
\def\macrosPSPendulumWaves{
    /TabLongueursPendules [
         0 1 np 1 sub {/indicePendule exch def
         gp Gamma 2 Pi mul N0 indicePendule add mul div dup mul mul
         } for
         ] def
         /y0 0.03 def
/asin {neg dup dup mul neg 1 add sqrt neg atan 180 sub} bind def
    /TabAlpha0 [
    0 1 np 1 sub {/iP exch def
        y0 TabLongueursPendules iP get div asin
        } for
    ] def
    /TabZPendules [
    0 1 np 1 sub {/iP exch def
        TabLongueursPendules iP get
        TabAlpha0 iP get cos mul
        } for
    ] def
%    /ti 5 def
    /TabAlphan {[
     0 1 np 1 sub {/iP exch def
        /Alpha TabAlpha0 iP get def
        /Omega 360 Gamma N0 iP add div div def
         Alpha Omega ti mul cos mul
        } for
    ] }def }%
\begin{document}
\maketitle
\begin{center}
\psset{unit=0.75}
\def\nImages{401}%  images
\begin{animateinline}[controls,loop,%palindrome,
                     begin={\begin{pspicture}(-4.1,-26.1)(4.1,1.1)},%
                     end={\end{pspicture}}]{5}% 5 images/s
\multiframe{\nImages}{r=0.0+0.05}{%
\psframe[fillstyle=solid,fillcolor=yellow!20](-4,-26)(4,1)
\psgrid[subgriddiv=1,gridcolor=lightgray,griddots=10,gridlabels=0pt](-4,-26)(4,1)
\pstVerb{/Hh 0 def /Hs 1 def /Hb 1 def /color {Hh Hs Hb} def /dH 1 15 div def}%
\multido{\i=14+-1}{15}{%
\definecolor[ps]{macouleur}{hsb}{color}%
\pstVerb{/ti \r\space def
/Gamma 20 def
         /N0 20 def % nombre d'oscillations de n=0
         /np 15 def % nombre de pendules (np+1)
         /gp 9.81 def % pesanteur
         /Pi 3.14159265359 def
         /di 1 def % distance entre 2 pendules en cm
\macrosPSPendulumWaves}%
    \pnode(!TabLongueursPendules \i\space get dup TabAlphan \i\space get sin mul 100 mul exch
             TabAlphan \i\space get cos mul neg 100 mul
            ){C}
    \Pendule%
\pstVerb{/Hh Hh dH add def}}%
\rput(0,0.5){\textbf{t=\r\,s}}\psdot(0,0)
\pstVerb{
    /Lx {gp Gamma 2 Pi mul N0 t di div add mul div dup mul mul} def
    /alpha0 {y0 Lx div asin} def
    /alphax {alpha0 360 ti mul Gamma div N0 t di div add mul cos mul} def
    }%
\parametricplot[linecolor=red,linestyle=dotted,linewidth=3\pslinewidth,plotpoints=360]{0}{14}{Lx alphax sin mul 100 mul Lx alphax cos mul neg 100 mul  }%
}
\end{animateinline}
\end{center}
\end{document}

Aucun commentaire:

Enregistrer un commentaire