Math
in package
Holds a bunch of static helper functions I could not find a better place for.
..
Table of Contents
Methods
- clamp() : float
- Clamps the given value between the given min and max
- lerp() : float
- Lerps between two values
- projectOnPlane() : Vec3
- Projects a vector onto a plane with the given normal
- quatFacingForwardTowardsTarget() : Quat
- Return a quaternion that will rotate the object to face forward to the target position The object is assumed to be facing forward along the forward vector The object is assumed to be facing up along the up vector
- rotationBetweenVectors() : Quat
- Calculate the rotation between two vectors
- sgn() : int
Methods
clamp()
Clamps the given value between the given min and max
public
static clamp(float $val, float $min, float $max) : float
Parameters
- $val : float
-
The value to clamp
- $min : float
-
The minimum value
- $max : float
-
The maximum value
Return values
floatlerp()
Lerps between two values
public
static lerp(float $a, float $b, float $t) : float
Parameters
- $a : float
-
The start value
- $b : float
-
The end value
- $t : float
-
The interpolation value
Return values
floatprojectOnPlane()
Projects a vector onto a plane with the given normal
public
static projectOnPlane(Vec3 $dir, Vec3 $normal) : Vec3
Parameters
- $dir : Vec3
- $normal : Vec3
Return values
Vec3quatFacingForwardTowardsTarget()
Return a quaternion that will rotate the object to face forward to the target position The object is assumed to be facing forward along the forward vector The object is assumed to be facing up along the up vector
public
static quatFacingForwardTowardsTarget(Vec3 $position, Vec3 $targetPosition, Vec3 $forward, Vec3 $up) : Quat
Parameters
- $position : Vec3
- $targetPosition : Vec3
- $forward : Vec3
- $up : Vec3
Return values
QuatrotationBetweenVectors()
Calculate the rotation between two vectors
public
static rotationBetweenVectors(Vec3 $start, Vec3 $dest) : Quat
Parameters
- $start : Vec3
- $dest : Vec3
Return values
Quatsgn()
public
static sgn(float $val) : int
Parameters
- $val : float