VISU - PHP Game Framework

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
float

lerp()

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
float

projectOnPlane()

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
Vec3

quatFacingForwardTowardsTarget()

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
Quat

rotationBetweenVectors()

Calculate the rotation between two vectors

public static rotationBetweenVectors(Vec3 $start, Vec3 $dest) : Quat
Parameters
$start : Vec3
$dest : Vec3
Return values
Quat

sgn()

public static sgn(float $val) : int
Parameters
$val : float
Return values
int

        
On this page

Search results