Documentation
¶
Index ¶
- func Clamp[T cmp.Ordered](low, high, value T) T
- func Degree(rad float64) float64
- func DifferenceDegrees(a, b float64) float64
- func Lerp(start float64, stop float64, amount float64) float64
- func NormalizeDegree(angle float64) float64
- func NormalizeDegreeInt(angle int) int
- func NormalizeRadian(angle float64) float64
- func Radian(deg float64) float64
- func RotationDirection(from float64, to float64) float64
- func Sign[T signed](n T) T
- func SignCmp[T cmp.Ordered](a, b T) int
- type Matrix3
- type Vector3
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clamp ¶
Clamp takes in a value and two thresholds. If the value is smaller than the low threshold, it returns the low threshold. If it's bigger than the high threshold it returns the high threshold. Otherwise it returns the value.
func DifferenceDegrees ¶
DifferenceDegrees returns the shortest angular difference between two angles in degrees.
func NormalizeDegree ¶
NormalizeDegree takes an angle in degrees and normalizes it to the range 0-360.
func NormalizeDegreeInt ¶
NormalizeDegreeInt takes an angle in degrees and normalizes it to the range 0-360.
func NormalizeRadian ¶
NormalizeRadian takes an angle in degrees and normalizes it to the range 0-360.
func RotationDirection ¶
RotationDirection calculates the optimal rotation direction between two angles.
Given two angles 'from' and 'to' in degrees, it returns:
-1.0 for clockwise rotation (shorter path) 1.0 for counter-clockwise rotation (shorter path) 0.0 if the angles are identical
The function considers all three possible paths (direct, +360°, -360°) and chooses the one with the smallest absolute angular distance.
Types ¶
type Matrix3 ¶
type Matrix3 [3]Vector3
Matrix3 defines a 3x3 matrix of float64 values.
func NewMatrix3 ¶
NewMatrix3 creates a 3x3 Matrix3.
func (Matrix3) Inverse ¶
Inverse inverses the M Matrix3. Returns false if m Matrix3 is not inversable.
func (Matrix3) Multiply ¶
Multiply applies the matrix to a 3D vector and returns the resulting vector.
func (Matrix3) MultiplyXYZ ¶
MultiplyXYZ takes x, y, z and creates 3D Vector3. Then Multiply m with the newly created Vector3. Returns the resulting vector.
type Vector3 ¶
type Vector3 [3]float64
Vector3 defines a 3D vector.
func NewVector3 ¶
NewVector3 create new 3D vector: Vector3.
func (Vector3) MultiplyMatrix ¶
MultiplyMatrix multiply Vector3 with given Matrix3.
func (Vector3) MultiplyScalar ¶
MultiplyScalar multiply all values using a scalar float64 and retuns a new Vector3.