A helper class for common math operations.

Constructors

Methods

  • Calculates the arccosine (inverse cosine) of a value.

    Parameters

    • value: number

      The value.

    Returns number

    The arccosine of the value in degrees.

  • Calculates the arcsine (inverse sine) of a value.

    Parameters

    • value: number

      The value.

    Returns number

    The arcsine of the value in degrees.

  • Calculates the arctangent (inverse tangent) of a value.

    Parameters

    • value: number

      The value.

    Returns number

    The arctangent of the value in degrees.

  • Clamps a value between a minimum and maximum value.

    Parameters

    • value: number

      The value to clamp.

    • min: number

      The minimum value.

    • max: number

      The maximum value.

    Returns number

    The clamped value.

  • Calculates the conjugate of a quaternion.

    Parameters

    • q: Float32Array

      The quaternion.

    Returns Float32Array

    A new quaternion representing the conjugate of q.

  • Calculates the cosine of an angle in degrees.

    Parameters

    • degrees: number

      The angle in degrees.

    Returns number

    The cosine of the angle.

  • Creates a quaternion from an axis and an angle.

    Parameters

    • axis: Point3D

      The rotation axis as a Point3D.

    • angle: number

      The rotation angle in degrees.

    Returns Float32Array

    A new quaternion as a Float32Array.

  • Creates a quaternion from Euler angles (in degrees).

    Parameters

    • x: number

      The rotation angle around the X-axis in degrees.

    • y: number

      The rotation angle around the Y-axis in degrees.

    • z: number

      The rotation angle around the Z-axis in degrees.

    Returns Float32Array

    A new quaternion as a Float32Array.

  • Creates a 4x4 identity matrix.

    Returns Float32Array

    A new 4x4 identity matrix as a Float32Array.

  • Linearly interpolates between two values.

    Parameters

    • t: number

      The interpolation factor (between 0 and 1).

    • a: number

      The first value.

    • b: number

      The second value.

    Returns number

    The interpolated value.

  • Maps a value from one range to another.

    Parameters

    • value: number

      The value to map.

    • inMin: number

      The minimum value of the input range.

    • inMax: number

      The maximum value of the input range.

    • outMin: number

      The minimum value of the output range.

    • outMax: number

      The maximum value of the output range.

    Returns number

    The mapped value.

  • Multiplies two 4x4 matrices.

    Parameters

    • a: Float32Array

      The first matrix.

    • b: Float32Array

      The second matrix.

    Returns Float32Array

    A new 4x4 matrix representing the product of a and b.

  • Multiplies two quaternions.

    Parameters

    • q1: Float32Array

      The first quaternion.

    • q2: Float32Array

      The second quaternion.

    Returns Float32Array

    A new quaternion representing the product of q1 and q2.

  • Normalizes a quaternion.

    Parameters

    • q: Float32Array

      The quaternion to normalize.

    Returns Float32Array

    A new normalized quaternion.

  • Generates a random integer within a specified range.

    Parameters

    • min: number

      The minimum value (inclusive).

    • max: number

      The maximum value (exclusive).

    Returns number

    A random integer within the range.

  • Creates a 4x4 rotation matrix around the X-axis.

    Parameters

    • angle: number

      The rotation angle in degrees.

    Returns Float32Array

    A new 4x4 rotation matrix as a Float32Array.

  • Creates a 4x4 rotation matrix around the Y-axis.

    Parameters

    • angle: number

      The rotation angle in degrees.

    Returns Float32Array

    A new 4x4 rotation matrix as a Float32Array.

  • Creates a 4x4 rotation matrix around the Z-axis.

    Parameters

    • angle: number

      The rotation angle in degrees.

    Returns Float32Array

    A new 4x4 rotation matrix as a Float32Array.

  • Converts a 4x4 rotation matrix to a quaternion.

    Parameters

    • m: Float32Array

      The rotation matrix as a Float32Array.

    Returns Float32Array

    A new quaternion as a Float32Array.

  • Calculates the sine of an angle in degrees.

    Parameters

    • degrees: number

      The angle in degrees.

    Returns number

    The sine of the angle.

  • Calculates the smoothstep value between two edges.

    Parameters

    • edge0: number

      The lower edge.

    • edge1: number

      The upper edge.

    • x: number

      The value to evaluate.

    Returns number

    The smoothstep value.

  • Calculates the tangent of an angle in degrees.

    Parameters

    • degrees: number

      The angle in degrees.

    Returns number

    The tangent of the angle.

  • Creates a 4x4 translation matrix.

    Parameters

    • x: number

      The translation in the x-axis.

    • y: number

      The translation in the y-axis.

    • z: number

      The translation in   the z-axis.

    Returns Float32Array

    A new 4x4 translation matrix as a Float32Array.