2023-10-23 15:45:18 +03:00
|
|
|
package gg
|
2023-05-27 18:00:27 +03:00
|
|
|
|
2023-05-28 19:14:02 +03:00
|
|
|
import (
|
|
|
|
"math"
|
|
|
|
)
|
|
|
|
|
2023-05-27 18:00:27 +03:00
|
|
|
// The type is used in all Engine interactions
|
|
|
|
// where you need floating values.
|
|
|
|
type Float = float64
|
|
|
|
|
|
|
|
const (
|
|
|
|
MaxFloat = math.MaxFloat64
|
2023-05-28 21:07:05 +03:00
|
|
|
Pi = math.Pi
|
2023-06-09 17:36:31 +03:00
|
|
|
RadDegrees = 57.2958
|
|
|
|
//PiRad = Pi * Rad
|
2023-05-27 18:00:27 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
// Returns square of the value.
|
|
|
|
func Sqr(v Float) Float {
|
|
|
|
return v * v
|
|
|
|
}
|
|
|
|
|
2023-06-09 17:36:31 +03:00
|
|
|
func Asin(v Float) Float {
|
|
|
|
return math.Asin(v)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Atan(v Float) Float {
|
|
|
|
return math.Atan(v)
|
|
|
|
}
|
|
|
|
|
2023-05-30 13:12:11 +03:00
|
|
|
func Sgn(v Float) Float {
|
|
|
|
if v > 0 {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if v < 0 {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2023-06-03 12:26:31 +03:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2023-05-28 21:07:05 +03:00
|
|
|
func RadiansToDegrees(v Float) Float {
|
2023-06-09 17:36:31 +03:00
|
|
|
return v/Pi * 180
|
2023-05-28 21:07:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func DeegresToRadians(v Float) Float {
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
2023-05-30 13:12:11 +03:00
|
|
|
|