[pstricks] [Fwd: Re: Simulation d'une chronophotographie ..]
Herbert Voss
Herbert.Voss at fu-berlin.de
Mon Jul 16 18:45:41 CEST 2007
-------- Original Message --------
Subject: Re: Simulation d'une chronophotographie ..
Date: Mon, 16 Jul 2007 18:38:48 +0200
From: Herbert Voss <herbert49 at googlemail.com>
Newsgroups: fr.comp.text.tex
Alexander Grahn wrote:
> Ceux qui n'ont pas Distiller peuvent créer l'animation avec ps2pdf et
> animate.sty:
>
> ftp://ftp.fzd.de/private/grahn/ball.pdf
> ftp://ftp.fzd.de/private/grahn/ball.tex
la même chose sans fp
Herbert
\documentclass[12pt,a4paper]{article}% by Jean-C?e Charpentier
% Herbert Voss, Manuel Luque,
%Alexander Grahn (animation)
% roulement sans glissement d'une bille
% sur un plan inclin?
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{animate}
\usepackage{pst-slpe,pstricks-add}
\newpsstyle{magenta40}{fillstyle=solid,fillcolor=magenta!40}
\newpsstyle{blue40}{fillstyle=solid,fillcolor=blue!60}
\newpsstyle{ball}{fillstyle=ccslope,slopebegin=white,
slopeend=black,slopecenter={0.6 0.6}}
\newcommand*\pente{30 }% inclinaison du plan/l'horizontale
\newcommand*\rBall{0.5 }% rayon de la bille
\newcommand*\Hauteur{1 } % hauteur du l?her
\makeatletter
\def\psset at plotpoints#1{\def\psk at plotpoints{#1 }}
\makeatletter
\def\Coeff{9.81 5 mul 7 div }
\def\Acceleration{\Coeff \pente sin mul }
\def\AccelerationAngulaire{\Coeff \pente sin mul \rBall div neg RadtoDeg }
\def\S#1{ % way as function of time, returns x y
0.5 \Acceleration mul #1 dup mul mul % S(t)
dup
\pente cos mul \rBall \pente sin mul add % Sx
exch
\pente sin mul neg \rBall \pente cos mul add \Hauteur add }% Sy
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% write external timeline file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newwrite\TimeLineFile
\immediate\openout\TimeLineFile=frames.txt
%first frame: axes+slope (transparency no. `0')
\immediate\write\TimeLineFile{::0}%
%remaining frames: ball w/ point & trajectory, axes+slope redrawn on top
\multido{\n=1+1}{40}{%
\immediate\write\TimeLineFile{::\n,0}%
}
\immediate\closeout\TimeLineFile
\begin{document}
\newcounter{count}
\noindent%
\begin{animateinline}[
begin={\begin{pspicture}(-0.6,-4.4)(10.3,2.2)},
end={\end{pspicture}},
width=\linewidth,
timeline=frames.txt,
controls]{10}
%%%%%%%%%%%%%%%
%axis and slope
%%%%%%%%%%%%%%%
\psaxes(0,0)(10.2,2)
\psline(0,\Hauteur)(!10 \pente cos mul 10 \pente sin mul neg \Hauteur add)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%ball, track-point and trajectory
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\whiledo{\thecount<40}{%
\gdef\time{0.0625 \thecount\space mul }
\newframe
% ball
\rput(! \S{\time} ){\pscircle[style=ball](0,0){\rBall}}
%track-point on ball surface
\parametricplot[plotpoints=2,linecolor=red,showpoints=true,linestyle=none]%
{\time}{\time}{%
/THETA \AccelerationAngulaire t dup mul mul 0.5 mul -120 add def
\S{t} /yPosG ED /xPosG ED
\rBall THETA cos mul xPosG add
\rBall THETA sin mul yPosG add
}
\parametricplot[
plotpoints={\time dup mul 2.5 dup mul div
360 mul cvi dup 2 lt {pop 2} if }]{0}{\time}{% trajectory
/THETA \AccelerationAngulaire t dup mul mul 0.5 mul -120 add def
\S{t} /yPosG ED /xPosG ED
\rBall THETA cos mul xPosG add
\rBall THETA sin mul yPosG add
}%
\stepcounter{count}%
}%
\end{animateinline}
\end{document}
--
http://PSTricks.tug.org
http://www.dante.de/CTAN/info/math/voss/
More information about the PSTricks
mailing list