Function rotationMat4v

  • Creates a 4x4 rotation matrix that rotates a given vector around an arbitrary axis by a specified angle.

    This function generates a rotation matrix for 3D transformations. The matrix will rotate vectors by an angle (anglerad) around a specified axis (axis). The resulting matrix is typically used in 3D rendering to rotate objects in space.

    Parameters

    • anglerad: number

      The angle of rotation in radians.

    • axis: FloatArrayParam

      The axis of rotation, represented as a 3D vector (x, y, z).

    • Optionalm: FloatArrayParam

      An optional destination matrix to store the result. If not provided, a new matrix will be created.

    Returns FloatArrayParam

    The resulting 4x4 rotation matrix. If m is provided, it will be modified; otherwise, a new matrix is returned.

    const axis = [0, 1, 0];  // Rotate around the y-axis
    const angle = Math.PI / 4; // 45 degrees in radians
    const matrix = rotationMat4v(angle, axis);
    console.log(matrix);
MMNEPVFCICPMFPCPTTAAATR