-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
60 lines (56 loc) · 1.19 KB
/
main.go
File metadata and controls
60 lines (56 loc) · 1.19 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"os"
gs "gravsim"
)
func main() {
bodies := []gs.Body{
gs.Body{
P: gs.Vec2{150.0,150.0},
V: gs.Vec2{10.0,0.0},
A: gs.Vec2{0.0,0.0},
M: 50000.0,
Radius: 15.0,
},
gs.Body{
P: gs.Vec2{350.0,150.0},
V: gs.Vec2{0.0,10.0},
A: gs.Vec2{0.0,0.0},
M: 50000.0,
Radius: 15.0,
},
gs.Body{
P: gs.Vec2{150.0,350.0},
V: gs.Vec2{0.0,-10.0},
A: gs.Vec2{0.0,0.0},
M: 50000.0,
Radius: 15.0,
},
gs.Body{
P: gs.Vec2{350.0,350.0},
V: gs.Vec2{-10.0,0.0},
A: gs.Vec2{0.0,0.0},
M: 50000.0,
Radius: 15.0,
},
}
system := &gs.System{
Bodies: bodies,
G: 1.0,
}
simulation := &gs.Simulation{
System: system,
X: 0,
Y: 0,
Dx: 500,
Dy: 500,
StepInterval: 0.04,
StepsPerFrame: 1,
TotalSteps: 2000,
}
f, err := os.Create("render.gif")
if err != nil {
panic(err)
}
simulation.Render(f)
}