26 lines
376 B
Go
26 lines
376 B
Go
package math
|
|
|
|
import (
|
|
stdmath "math"
|
|
)
|
|
|
|
type Direction float64
|
|
|
|
func (d *Direction) Set(v float64) {
|
|
*d = Direction(v)
|
|
}
|
|
|
|
func (d Direction) Get() float64 {
|
|
return float64(d)
|
|
}
|
|
|
|
func (d Direction) ForwardVector() Vec2f {
|
|
return Vec2f{
|
|
X: stdmath.Cos(float64(d)),
|
|
Y: stdmath.Sin(float64(d)),
|
|
}
|
|
}
|
|
|
|
func (d *Direction) Rotate(delta float64) {
|
|
*d += Direction(delta)
|
|
}
|