Moving to the secret built in 'sign' method, and adding lerp
@@ -75,14 +75,7 @@ class Math {
}
static sign(a) {
- assertNum(a)
- if (a < 0) {
- return -1
- } else if (a > 0) {
- return 1
- } else {
- return 0
- }
+ return a.sign
}
static mid(a, b, c) {
@@ -107,6 +100,15 @@ class Math {
return c
}
}
+
+ static lerp(low, value, high) {
+ assertNum(low)
+ assertNum(value)
+ assertNum(high)
+
+ var v = mid(0, value, 1)
+ return (1 - v) * low + v * high
+ }
}
var M = Math
