Skip to main content

Class: MathUtils

A utility class for doing math operations.

Methods​

directionToQuaternion​

▸ directionToQuaternion(dx, dy, dz): Quaternion

Convert a direction vector to a quaternion.

Parameters​

NameTypeDescription
dxnumberX component of the direction vector.
dynumberY component of the direction vector.
dznumberZ component of the direction vector.

Returns​

Quaternion

The quaternion representing the direction vector.


normalizeAngle​

▸ normalizeAngle(angle): number

Normalizes an angle to be between -2PI and 2PI.

Parameters​

NameTypeDescription
anglenumberThe angle to normalize.

Returns​

number

The normalized angle.


round​

▸ round(n, digits): number

Round a number to a given precision.

Parameters​

NameTypeDescription
nnumberThe number to round.
digitsnumberThe number of digits after decimal to round to.

Returns​

number

The rounded number.


swimDirectionToQuaternion​

▸ swimDirectionToQuaternion(dx, dy, dz): Quaternion

Parameters​

NameType
dxnumber
dynumber
dznumber

Returns​

Quaternion