-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.go
50 lines (43 loc) · 1.44 KB
/
data.go
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
package main
// Universe contains a slice of pointers to stars and a width parameter.
// We conceptualize the universe as a square -- stars may go outside the universe
// but the width dictates relative distances when drawing the universe.
type Universe struct {
stars []*Star
width float64
}
// Galaxy is a potentially useful object holding a list of star positions
type Galaxy struct {
g []*Star
}
// Star is analogous to the "Body" object from the jupiter simulations.
type Star struct {
position, velocity, acceleration OrderedPair
mass float64
radius float64
red, blue, green uint8
}
//OrderedPair represents a point or vector.
type OrderedPair struct {
x float64
y float64
}
//QuadTree simply contains a pointer to the root.
//Another way of doing this would be type QuadTree *Node
type QuadTree struct {
root *Node
}
//Node object contains a slice of children (this could just as easily be an array of length 4).
//A node refers to a star. Sometimes, the star will be a "dummy" star, sometimes it is a star in the
//universe, and sometimes it is nil. Every internal node points to a dummy star.
type Node struct {
children []*Node
star *Star
sector Quadrant
}
//Quadrant is an object representing a sub-square within a larger universe.
type Quadrant struct {
x float64 //bottom left corner x coordinate
y float64 //bottom right corner y coordinate
width float64
}