-
Notifications
You must be signed in to change notification settings - Fork 0
/
orientation.go
46 lines (38 loc) · 912 Bytes
/
orientation.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
package opengl
import "github.com/go-gl/mathgl/mgl32"
type orientation struct {
angle float32
dir mgl32.Vec3
variable string
}
func createOrientation(
angle float32,
dir mgl32.Vec3,
variable string,
) Orientation {
out := orientation{
angle: angle,
dir: dir,
variable: variable,
}
return &out
}
// Angle returns the angle
func (obj *orientation) Angle() float32 {
return obj.angle
}
// Direction returns the direction
func (obj *orientation) Direction() mgl32.Vec3 {
return obj.dir
}
// Variable returns the variable
func (obj *orientation) Variable() string {
return obj.variable
}
// Add adds an orientation
func (obj *orientation) Add(orientation Orientation) Orientation {
vec := orientation.Direction()
updatedDirection := obj.dir.Add(vec)
updatedAngle := obj.angle + orientation.Angle()
return createOrientation(updatedAngle, updatedDirection, obj.variable)
}