package mx import ( "math" ) // The type is used in all Engine interactions // where you need floating values to keep // it interchangable in future. // Not much promise for this though. type Float = float64 const ( MaxFloat = math.MaxFloat64 Pi = math.Pi RadDegrees = 57.2958 //PiRad = Pi * Rad EqualityThreshold = 1e-9 ) func IsNan(v Float) bool { return math.IsNaN(v) } func IsInf(f Float, sign int) bool { return math.IsInf(f, sign) } func Degree(f Float) Float { return (f/(2*Pi))*360 } // Returns square of the value. func Sqr(v Float) Float { return v * v } func Sqrt(v Float) Float { return math.Sqrt(v) } func Asin(v Float) Float { return math.Asin(v) } func Atan(v Float) Float { return math.Atan(v) } func Sgn(v Float) Float { if v > 0 { return 1 } if v < 0 { return -1 } return 0 } func Max(v1, v2 Float) Float { if v1 > v2 { return v1 } return v2 } func Min(v1, v2 Float) Float { if v1 < v2 { return v1 } return v2 } func Abs(v Float) Float { if v >= 0 { return v } return -v } func RadiansToDegrees(v Float) Float { return v/Pi * 180 } func DeegresToRadians(v Float) Float { return v } // Returns whether the two floats are nearly equal. func Neq(a, b Float) bool { return Abs(a-b) <= EqualityThreshold }