-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkml.go
97 lines (72 loc) · 1.13 KB
/
kml.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package kml
import (
"math"
)
const TO_RAD float32 = 0.0174532925
const TO_DEG float32 = 57.2957795
func Sinf(f float32) float32 {
return float32(math.Sin(float64(f)))
}
func Cosf(f float32) float32 {
return float32(math.Cos(float64(f)))
}
func Fabs(f float32) float32 {
return float32(math.Abs(float64(f)))
}
func Sign(f float32) float32 {
if f > 0 {
return 1.0
}
if f < 0 {
return -1.0
}
return 0.0
}
func AbsInt(a int) int {
if a < 0 {
return -a
}
return a
}
func Deadzone(v, dzone float32) float32 {
if Fabs(v) < dzone {
return 0
}
return v
}
func Clamp(v, min, max float32) float32 {
if v > max {
return max
}
if v < min {
return min
}
return v
}
func Maxf(v0, v1 float32) float32 {
if v0 > v1 {
return v0
}
return v1
}
func Minf(v0, v1 float32) float32 {
if v0 < v1 {
return v0
}
return v1
}
func Saturatef(v float32) float32 {
if v < 0.0 {
return 0.0
}
if v > 1.0 {
return 1.0
}
return v
}
func Gamma(v, gamma float32) float32 {
return Fabs(float32(math.Pow(float64(v), float64(gamma)))) * Sign(v)
}
func Lerpf(v0, v1, b float32) float32 {
return v0*(1.0-b) + v1*b
}