Documentation
¶
Index ¶
- Constants
- func Clamp[T cmp.Ordered](low, high, value T) T
- func Degree(rad float64) float64
- func DifferenceDegrees(from, to 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, to float64) float64
- func Sign[T signed](n T) T
- func SignCmp[T cmp.Ordered](a, b T) int
- type Matrix3
- type Vector3
- func (v Vector3) Add(vec Vector3) Vector3
- func (v Vector3) Dot(vec Vector3) float64
- func (v Vector3) Map(f func(float64) float64) Vector3
- func (v Vector3) MulElems(vec Vector3) Vector3
- func (v Vector3) Scaled(s float64) Vector3
- func (v Vector3) String() string
- func (v Vector3) Values() (float64, float64, float64)
- type VectorLike
Constants ¶
const ( // Clockwise indicates a clockwise rotaion. Clockwise = 1 // CounterClockwise indicates a counter-clockwise rotaion. CounterClockwise = -1 // NoRotation indicates two angles are same. NoRotation = 0 )
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 absolute shortest angular difference.
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. It uses math.Remainder to find the shortest signed distance.
Types ¶
type Matrix3 ¶
type Matrix3 [9]float64
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.
type Vector3 ¶
type Vector3 [3]float64
Vector3 defines a 3D vector.
func NewVector3 ¶
NewVector3 create new 3D vector: Vector3.
func (Vector3) Map ¶
Map returns a new Vector3 where each component of v has been transformed by the given func f. Returns a new Vector3.
func (Vector3) MulElems ¶
MulElems multiplies v Vector3 with given Vector3 element-wise and returns a new Vector3.
type VectorLike ¶
VectorLike is any data that has 3 float64 values. Usually a color model.