source: Sophya/trunk/SophyaPI/DemoPIApp/oh_xva_spring.pic@ 3461

Last change on this file since 3461 was 2787, checked in by ansari, 20 years ago

Ajout script trace fihure oscillateur harmonique - Reza 30 Mai 2005

File size: 2.7 KB
Line 
1# Illustration de cours S1SM - Oscillateur harmonique
2# Reza Ansari - Decembre 2003
3
4# Script de trace de ressort vertical
5
6defscript spring 'trace de ressort '
7# $1 : Nombre de zigzag
8# $2 : Position de ressort en X
9# $3,$4 : Position YMin,YMax du ressort
10 set ns $1
11 rpneval x1 $2 0.2 -
12 rpneval x2 $2 0.2 +
13 set ymin $3
14 set ymax $4
15 rpneval dy $ymax $ymin - $ns 2 * .5 + /
16 set yc $ymin
17 for i 0:$ns
18 set y1 $yc
19 rpneval y2 $y1 $dy +
20 addline $x1 $y1 $x2 $y2
21 rpneval y1 $y1 $dy +
22 rpneval y2 $y2 $dy +
23 addline $x2 $y1 $x1 $y2
24 rpneval yc $yc $dy 2 * +
25 end
26 rpneval x2 $x2 0.2 -
27 set y1 $yc
28 rpneval y2 $yc $dy 0.5 * +
29 addline $x1 $y1 $x2 $y2
30endscript
31
32# Illustration cours Mouvement oscillateur harmonique
33# Trace position,vitesse,acceleration x(t), v(t), a(t)
34zone 1
35
36func sin(x) -0.5 10. 100 'axesnone xylimits=-1,10.5,-7,1.5 normalline blue'
37func cos(x) -0.5 10. 100 'same xylimits=-1,10.,-7,1.5 normalline magenta'
38func -sin(x) -0.5 10. 100 'same xylimits=-1,10.5,-7,1.5 normalline red'
39addtext 2 1.2 'Position' 'blue bigboldfont helveticafont horizcenter'
40addtext 6.5 1.2 'Vitesse' 'magenta bigboldfont helveticafont horizcenter'
41addtext 3.7 0.5 'Acc/Force' 'red bigboldfont helveticafont horizcenter vertcenter'
42
43# Trace d'axes
44addarrow -1 0 10 0 'ftrianglearrow7'
45addtext 7 -0.5 'Temps' 'bigboldfont helveticafont horizcenter'
46addfrect -1 -6.5 10 -6. 'grey normalline'
47addline -1 -6.5 10 -6.5 'normalline'
48addline -1 -6. 10 -6. 'normalline'
49
50# Trace vecteur vitesse, acceleration pour t=2pi/kk
51for kk 0:7
52 rpneval x pi 2 / $kk *
53 rpneval ym $x sin 3 -
54 addmarker $x $ym 'blue marker=fbox,11'
55 spring 8 $x -6 $ym
56 rpneval vv $x cos 1 *
57 rpneval avv $vv fabs
58 set yv0 $ym
59 rpneval yv1 $yv0 $vv +
60 rpneval xv $x 0.3 -
61 if ( $avv > 0.5 ) then
62 addarrow $xv $yv0 $xv $yv1 'magenta ftrianglemarker9 normalline'
63 rpneval xv $xv 0.05 -
64 rpneval yv0 $yv0 $yv1 + 0.5 *
65 addtext $xv $yv0 'V' 'magenta bigboldfont helveticafont horizright vertcenter'
66 else
67 rpneval yv0 $yv0 $yv1 + 0.5 *
68 addtext $xv $yv0 'V=0' 'magenta bigboldfont helveticafont horizright vertcenter'
69 endif
70 rpneval aa $x sin -1 *
71 rpneval aaa $aa fabs
72 set ya0 $ym
73 rpneval ya1 $ya0 $aa +
74 rpneval xa $x 0.3 +
75 if ( $aaa > 0.5 ) then
76 addarrow $xa $ya0 $xa $ya1 'red ftrianglemarker9 normalline'
77 rpneval xa $xa 0.05 +
78 rpneval ya0 $ya0 $ya1 + 0.5 *
79 addtext $xa $ya0 'F' 'red bigboldfont helveticafont horizleft vertcenter'
80 else
81 rpneval ya0 $ya0 $ya1 + 0.5 *
82 addtext $xa $ya0 'F=0' 'red bigboldfont helveticafont horizleft vertcenter'
83 endif
84end
85
86# On en fait un fichier postscript
87w2eps oh_xva_spring.eps
88
Note: See TracBrowser for help on using the repository browser.