Ajouté un dossier "gravitation" ...
[pst-eqdf.git] / gravitation / pst-eqdf.tex
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -*- Mode: Latex -*- %%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %% pst-eqdf.tex --- plotting of differential equations
3 %% Copyright 2004 Dominique RODRIGUEZ
4 %%
5 %% Author : Dominique RODRIGUEZ (EN) <dominique.rodriguez@waika9.com>
6 %% Created the : ven avr 2 22:02:01 CEST 2004
7 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8 %% HISTORY
9 %%
10 %% 2004-04-04 : creation of the file from a first LaTeX protype sty file
11 %%
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 \def\fileversion{pre-1.0}
14 \def\filedate{2004/03/21}%
15 %% This program can be redistributed and/or modified under the terms
16 %% of the LaTeX Project Public License Distributed from CTAN
17 %% archives in directory macros/latex/base/lppl.txt.
18 %% adapation de M.Luque juin 2012 pour
19 %% sauvegarde de tableaux de valeurs
20 \message{`PST-Equadiff v\fileversion, \filedate\space (Dominique RODRIGUEZ)}%
21 \csname PSTEquadiffLoaded\endcsname
22 \let\PSTEquadiffLoaded\endinput
23 % Require PSTricks and pst-node packages
24 \ifx\PSTricksLoaded\endinput\else \input pstricks \fi
25 \ifx\PSTplotLoaded\endinput\else \input pst-plot.tex\fi
26 \ifx\PSTXKeyLoaded\endinput\else \input pst-xkey.tex \fi
27 \edef\PstAtCode{\the\catcode`\@}%
28 \catcode`\@=11\relax
29 % Definition of the parameters
30 % ----------------------------
31 \pst@addfams{pst-eqd}
32 \define@key[psset]{pst-eqd}{method}{\edef\psk@method{#1}}%
33 \define@key[psset]{pst-eqd}{whichabs}{\edef\psk@whichabs{#1}}%
34 \define@key[psset]{pst-eqd}{whichord}{\edef\psk@whichord{#1}}%
35 \define@key[psset]{pst-eqd}{plotfuncx}{\edef\psk@plotfuncx{#1}}%
36 \define@key[psset]{pst-eqd}{plotfuncy}{\edef\psk@plotfuncy{#1}}%
37 \define@key[psset]{pst-eqd}{tabname}{\edef\psk@tabname{#1}}%
38 \define@key[psset]{pst-eqd}{filename}{\edef\psk@filename{#1}}%
39 \newif\ifPst@buildvector%
40 \define@key[psset]{pst-eqd}{buildvector}[true]{\@nameuse{Pst@buildvector#1}}%
41 \newif\ifPst@saveData%
42 \define@key[psset]{pst-eqd}{saveData}[true]{\@nameuse{Pst@saveData#1}}%
43 \psset[pst-eqd]{method=default, whichabs={}, whichord={}, filename=datas.dat,
44 plotfuncx={}, plotfuncy={}, buildvector=false, tabname=tabValues, saveData=false}
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46 \SpecialCoor%% for using polar coordinates, node position, ...
47 \psset{dimen=middle}%
48 \def\@undef{undef}%
49 \def\@default{default}%
50 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51 %% #1-#2 x range
52 %% #3 initial value of y (which is a vector)
53 %% #4 value of the dérivative (y and t can be used)
54 \def\psequadiff{\def\pst@par{}\pst@object{psequadiff}}
55 \def\psequadiff@i#1#2#3#4{%
56 \pst@killglue
57 \begingroup
58 \use@par
59 % \addto@pscode{%
60 \pstVerb{
61 /x #1 def
62 /x1 #2 def
63 /y [ #3 ] def
64 /ylength y length def
65 /addvect
66 { /len exch def 1 1 len
67 { /i exch def len i sub 2 add -1 roll add len 2 mul i sub 1 roll } for } def
68 /dx x1 x sub \psk@plotpoints div def
69 /mulvect { exch 1 index { dup 4 -1 roll mul 2 index 2 add 1 roll } repeat pop pop } def
70 /divvect { exch 1 index { dup 4 -1 roll exch div 2 index 2 add 1 roll } repeat pop pop } def
71 /k0 0 def /k1 0 def /k2 0 def /k3 0 def
72 \ifPst@algebraic /F@pstplot (#4) AlgParser cvx def \fi
73 /Func {
74 \ifPst@algebraic F@pstplot ylength array astore
75 \else
76 \ifPst@buildvector\else y aload pop \fi #4
77 \ifPst@buildvector\else ylength array astore \fi
78 \fi
79 } def
80 /xy {
81 \ifx\psk@method\@default%
82 \ifx\psk@plotfuncx\@empty
83 \ifx\psk@whichabs\@empty x \else y \psk@whichabs\space get \fi%
84 \else\psk@plotfuncx\space\fi%
85 % \pst@number\psxunit mul
86 y /y Func { dx mul } forall y aload pop ylength addvect ylength array astore def
87 \ifx\psk@plotfuncy\@empty
88 \ifx\psk@whichord\@empty 0 \else\psk@whichord\space\fi get %
89 \else\psk@plotfuncy\space\fi
90 \else%
91 \ifx\psk@plotfuncx\@empty
92 \ifx\psk@whichabs\@empty x \else y \psk@whichabs\space get \fi%
93 \else\psk@plotfuncx\space\space\fi%
94 y /k0 Func { dx mul } forall ylength array astore def %% y
95 dup aload pop k0 { 2 div } forall ylength addvect ylength array astore /y exch def %
96 x dup dx 2 div add /x exch def %% y x
97 /k1 Func { dx mul } forall ylength array astore def %% y x
98 exch dup aload pop k1 { 2 div } forall ylength addvect y astore pop %% x y
99 /k2 Func { dx mul } forall ylength array astore def %% x y
100 dup aload pop k2 aload pop ylength addvect y astore pop exch dup dx add /x exch def %% y x
101 /k3 Func { dx mul } forall ylength array astore def %% y x
102 /x exch def %% y
103 dup aload pop k0 aload pop k1 aload pop k2 aload pop ylength addvect
104 2 ylength mulvect ylength addvect k3 aload pop ylength addvect
105 6 ylength divvect ylength addvect y astore pop
106 \ifx\psk@plotfuncy\@empty
107 \ifx\psk@whichord\@empty 0 \else\psk@whichord\space\fi get %
108 \else\psk@plotfuncy\space\fi
109 \fi
110 } def
111 /\psk@tabname[
112 \psk@plotpoints {
113 xy
114 /x x dx add
115 def
116 } repeat
117 /x x1 def
118 xy
119 ] def
120 \ifPst@saveData
121 /fichierpoints (\psk@filename) (w) file def
122 0 2 \psk@tabname\space length 2 sub {/i exch def
123 /xi \psk@tabname\space i get def
124 /yi \psk@tabname\space i 1 add get def
125 fichierpoints xi 15 string cvs writestring
126 fichierpoints 32 write %% espace
127 fichierpoints yi 15 string cvs writestring
128 fichierpoints 32 write %% espace
129 fichierpoints 10 write %% CR
130 } for
131 fichierpoints closefile
132 \fi
133 }%
134 \endgroup
135 \ignorespaces}
136 %%% Local Variables:
137 %%% mode: latex
138 %%% TeX-master: t
139 %%% End:

Licence Creative Commons Les fichiers de Syracuse sont mis à disposition (sauf mention contraire) selon les termes de la
Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Partage dans les Mêmes Conditions 4.0 International.