1 \documentclass{article
}
2 \usepackage[a4paper,margin=
2cm
]{geometry
}
3 \usepackage[latin1]{inputenc}
4 \usepackage{pstricks,pst-eqdf
}
6 \newpsstyle{vecteurA
}{arrowinset=
0.05,arrowsize=
0.125,linecolor=
{[rgb
]{1 0.5 0}}}
7 \newpsstyle{vecteurB
}{arrowinset=
0.05,arrowsize=
0.1,linecolor=
{[rgb
]{0 0.7 1}}}
8 \newpsstyle{vecteurC
}{arrowinset=
0.1,arrowsize=
0.2,linecolor=
{[rgb
]{1 0.5 0}}}
10 \title{Animation du mouvement d'un satellite
}
13 \begin{filecontents
}{satellite.dat
}
68 \newcommand{\Jupiter}{%
69 \psclip{\pscircle[fillstyle=solid,fillcolor=yellow
]{1.5}}
70 \psset{fillstyle=solid,fillcolor=
{[cmyk
]{0 0.2 0.4 0}},linestyle=none
}
72 \psframe(-
2,
0.45)(
2,
0.52)
73 \psframe(-
2,
.05)(
2,
.3)
74 \psframe(-
2,-
0.35)(
2,-
0.2)
75 \psframe(-
2,-
0.9)(
2,-
.5)
77 \psellipse[fillstyle=solid,fillcolor=
{[cmyk
]{0 0.4 0.6 0}},linestyle=none
](-
0.3,-
0.6)(
0.35,
0.2)
80 %% adapté de \psRandom du package pstricks-add
81 %% pour rendre aléatoire la taille des étoiles
84 \def\psset@sizeStar
#1{\pssetlength\pssizeStar{#1}}
86 \define@key
[psset
]{pst-eqd
}{randomPoints
}[1000]{\def\psk@randomPoints
{#1}}
87 \psset[pst-eqd
]{randomPoints=
1000}
88 \define@boolkey
[psset
]{pst-eqd
}[Pst@
]{color}[true
]{}
89 \psset[pst-eqd
]{color=false
}
90 \def\psRandomStar{\pst@object
{psRandomStar
}}%
91 \def\psRandomStar@i
{\@ifnextchar(
{\psRandomStar@ii
}{\psRandomStar@iii(
0,
0)(
1,
1)
}}
92 \def\psRandomStar@ii(
#1)
{\@ifnextchar(
{\psRandomStar@iii(
#1)
}{\psRandomStar@iii(
0,
0)(
#1)
}}
93 \def\psRandomStar@iii(
#1)(
#2)
#3{%
95 \ifx\pst@tempA
\pst@empty
\psclip{\psframe(
#2)
}\else\psclip{#3}\fi
96 \pst@getcoor
{#1}\pst@tempA
97 \pst@getcoor
{#2}\pst@tempB
100 \pst@tempA
\space /yMin exch def
102 \pst@tempB
\space /yMax exch def
104 /dy yMax yMin sub def
105 /dx xMax xMin sub def
106 rrand srand
% initializes the random generator
107 /getRandReal
{ rand
2147483647 div
} def
109 /DS
\pst@number
\pssizeStar\space getRandReal mul def
110 \@nameuse
{psds@
\psk@dotstyle
}
111 \ifPst@
color getRandReal
1 1 sethsbcolor
\fi
112 getRandReal dx mul xMin add
113 getRandReal dy mul yMin add
115 \ifx\psk@fillstyle
\psfs@solid fill
\fi stroke
125 y
[2]|y
[3]|-GM*y
[0]/((sqrt(y
[0]^
2+y
[1]^
2))^
3)|-GM*y
[1]/((sqrt(y
[0]^
2+y
[1]^
2))^
3)
}%
127 %\begin{pspicture}(-10,-10)(6,6)
128 \def\nFrames{50}% 50 images
129 \begin{animateinline
}[controls,loop,timeline=satellite.dat,
%
130 begin=
{\begin{pspicture
}(-
10,-
10)(
6,
6)
},
131 end=
{\end{pspicture
}}]{5}% 5 images/s
132 %\uput[r](0,3){$y$}\uput[u](3,0){$x$}
134 \psframe*
[linecolor=
{[cmyk
]{1 1 0 0.7}}](-
10,-
10)(
6,
6)
135 \psRandomStar[linecolor=
{[rgb
]{1,
1,
0.5}},
136 randomPoints=
1000,sizeStar=
1.25pt
](-
10,-
10)(
6,
6)
{\psframe[linestyle=none
](-
10,-
10)(
6,
6)
}
137 \pstVerb{/tabXiYi
[(XiYi.dat) run
] def
}%
141 /x0 r0 theta0 cos mul def
142 /y0 r0 theta0 sin mul def
144 /v0x v0 theta0 sin mul neg def
145 /v0y v0 theta0 cos mul def
146 /Lc r0 v0 mul def
% moment cinetique
147 /par Lc dup mul GM div def
% paramètre de l'ellipse
149 /exc
1 0.5 v0
4 exp mul r0 dup mul mul GM r0 mul v0 dup mul mul sub GM dup mul div
2 mul add sqrt def
151 /a_2 par
1 exc dup mul sub div def
% demi-grand axe
152 /b_2 par
1 exc dup mul sub sqrt div def
% demi-petit axe
153 /periode
2 3.1416 dup mul a_2
3 exp mul GM div sqrt mul def
}%
154 \psequadiff[method=rk4,
160 % saveData,filename=XiYi.dat
161 ]{0}{43}{x0 y0 v0x v0y
}{\eqsatellite}%
162 \listplot[linecolor=gray,unit=
2]{XiYi aload pop
}
163 \psequadiff[method=rk4,
169 % saveData,filename=vxvy.dat
170 ]{0}{43}{x0 y0 v0x v0y
}{\eqsatellite}%
171 %\listplot[unit=2,linecolor=red]{vxvy aload pop}
172 % on dessine la vitesse un point sur 50
173 %\pscircle[fillcolor=gray!70,fillstyle=solid,unit=2](0,0){0.4}
175 %\psgrid[subgriddiv=2,gridcolor=lightgray,gridlabels=8pt,unit=2](-5,-5)(3,3)
176 %\psline[arrowinset=0.05,arrowsize=0.1,unit=2]{<->}(3,0)(0,0)(0,3)
178 \multiframe{\nFrames}{i=
0+
40}{
180 \pstVerb{/tabXYpartiel
{
181 2 2 \i\space {/I exch def
186 /vX vxvy
\i\space get def
187 /vY vxvy
\i\space 1 add get def
188 /xi tabXiYi
\i\space get def
189 /yi tabXiYi
\i\space 1 add get def
190 /ri3 xi dup mul yi dup mul add sqrt
3 exp def
191 /Fx xi ri3 div neg def
192 /Fy yi ri3 div neg def
}%
193 \listplot[linecolor=red,linewidth=
0.05]{tabXYpartiel
}
194 \rput(!xi yi)
{\pscircle[fillstyle=solid,fillcolor=gray!
50]{0.075}\psline[style=vecteurA
]{->
}(! vX
2 mul vY
2 mul)
\psline[style=vecteurB
]{->
}(! Fx
5 mul Fy
5 mul)
}}
196 \listplot[linecolor=gray,unit=
2]{XiYi aload pop
}
197 \listplot[linecolor=red,unit=
2,linewidth=
0.05]{XiYi aload pop
}
199 \rput(!x0 y0)
{\pscircle[fillstyle=solid,fillcolor=gray!
50]{0.075}\psline[style=vecteurA
]{->
}(! v0x
2 mul v0y
2 mul)
\psline[style=vecteurB
]{->
}(! x0 r0
3 exp div
5 mul neg y0 r0
3 exp div
5 mul neg)
}