forked from andeya/algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular_velocity.go
More file actions
41 lines (31 loc) · 960 Bytes
/
Copy pathangular_velocity.go
File metadata and controls
41 lines (31 loc) · 960 Bytes
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
package units
import (
"math"
"time"
)
type AngularVelocity float64
const (
MilliradianPerSecond AngularVelocity = 1
RadianPerSecond = MilliradianPerSecond * 1e3
DegreePerSecond = RadianPerSecond * 360.0 / (2.0*math.Pi)
GradianPerSecond = RadianPerSecond * 400.0 / (2.0*math.Pi)
)
func (v AngularVelocity) MilliradiansPerSecond() float64 {
return float64(v)/float64(Milliradian)
}
func (v AngularVelocity) RadiansPerSecond() float64 {
return float64(v)/float64(Radian)
}
func (v AngularVelocity) DegreesPerSecond() float64 {
return float64(v)/float64(Degree)
}
func (v AngularVelocity) GradiansPerSecond() float64 {
return float64(v)/float64(Gradian)
}
func (v AngularVelocity) MultiplyWithDuration(t time.Duration) Angle {
return Angle(float64(v)*float64(t)/float64(time.Second))
}
// Backwards compatibility only!
//func TimesAngularVelocityDuration(v AngularVelocity, t time.Duration) Angle {
// return v.MultiplyWithDuration(t)
//}