File: orbit.ode

package info (click to toggle)
plotutils 2.4.1-11
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 11,676 kB
  • ctags: 6,967
  • sloc: ansic: 76,305; sh: 15,172; cpp: 12,403; yacc: 2,604; makefile: 888; lex: 144
file content (41 lines) | stat: -rw-r--r-- 1,036 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# This example does a planetary orbit simulation, with two suns situated at
# (0,0) and (-5,0) and one planet starting out at (1,0).  You may run it by
# typing

#    ode -f orbit.ode | graph -T X -C -y -1 3 -x -6 2
#    step 0,10
#    step 10,20
#    step 20,30
#    step 30,40
#    step 40,50
#    step 50,60
#    .

# The planet's orbit will be traced out incrementally.  If you are using a
# color X Window System display, each segment of the orbit will be a
# different color.  This is a feature provided by `graph', which normally
# changes the linemode after each dataset it reads. If you do not like this
# feature, you may turn it off by using `graph -B' instead of `graph'.

# x and y are positions
# vx and vy are velocities

vx' = -x/((x^2+y^2)^(3/2)) -(x+5)/(((x+5)^2+y^2)^(3/2))
vy' = -y/((x^2+y^2)^(3/2)) -y/(((x+5)^2+y^2)^(3/2))
y' = vy
x' = vx

x = 1
y = 0

print x,y every 5

# these values seem to give a nice orbit:
# vx = 0
# vy = 1.142

# a more exciting result can be obtained from:
vx = 0
vy = 1.165

#step 0,20