Request

Response

    Autodesk.Viewing.Math
    Version 8 preview
    This page documents a preview of the Viewer SDK v8. APIs and content can still change before the final release.

    Matrix4

    new Matrix4(useDoublePrecision)

    Represents a 4x4 matrix

    Parameters

    useDoublePrecision
    boolean
    Whether to use double precision (Float64Array) or single precision (Float32Array)

    Properties

    elements
    Float32Array, Float64Array
    A column-major list of matrix values. Precision is set on construction.
    isDoublePrecision
    boolean
    Whether the matrix uses double precision (Float64Array) or single precision (Float32Array).

    Methods

    set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44)

    Set the components of this matrix.

    Parameters

    n11*
    number
    Component 1-1.
    n12*
    number
    Component 1-2.
    n13*
    number
    Component 1-3.
    n14*
    number
    Component 1-4.
    n21*
    number
    Component 2-1.
    n22*
    number
    Component 2-2.
    n23*
    number
    Component 2-3.
    n24*
    number
    Component 2-4.
    n31*
    number
    Component 3-1.
    n32*
    number
    Component 3-2.
    n33*
    number
    Component 3-3.
    n34*
    number
    Component 3-4.
    n41*
    number
    Component 4-1.
    n42*
    number
    Component 4-2.
    n43*
    number
    Component 4-3.
    n44*
    number
    Component 4-4.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    identity()

    Set this matrix to the identity matrix.

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    copy(m)

    Copy the components from another matrix.

    Parameters

    m*The matrix to copy.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    makeRotationFromQuaternion(q)

    Set this matrix to a rotation matrix from a quaternion.

    Parameters

    q*The quaternion.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    multiply(n)

    Multiply this matrix by another matrix.

    Parameters

    n*The matrix to multiply by.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    multiplyMatrices(a, b)

    Set this matrix to the product of two matrices.

    Parameters

    a*The first matrix.
    b*The second matrix.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    multiplyScalar(s)

    Multiply this matrix by a scalar.

    Parameters

    s*
    number
    The scalar to multiply by.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    determinant()

    Calculate the determinant of this matrix.

    Returns

    typedescription
    number The determinant.

    transpose()

    Transpose this matrix.

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    setPosition(v)

    Set the position component of this matrix.

    Parameters

    v*The position vector.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    invert()

    Invert this matrix.

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    scale(v)

    Scales the first column by v.x, the second column by v.y and the third column by v.z.

    Parameters

    v*The scale vector.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    getMaxScaleOnAxis()

    Get the maximum scale value on any axis.

    Returns

    typedescription
    number The maximum scale.

    makeTranslation(x, y, z)

    Set this matrix to a translation matrix.

    Parameters

    x*
    number
    The x translation.
    y*
    number
    The y translation.
    z*
    number
    The z translation.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    makeRotationX(theta)

    Set this matrix to a rotation matrix around the X axis.

    Parameters

    theta*
    number
    The rotation angle in radians.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    makeRotationY(theta)

    Set this matrix to a rotation matrix around the Y axis.

    Parameters

    theta*
    number
    The rotation angle in radians.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    makeRotationZ(theta)

    Set this matrix to a rotation matrix around the Z axis.

    Parameters

    theta*
    number
    The rotation angle in radians.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    makeRotationAxis(axis, angle)

    Set this matrix to a rotation matrix around an arbitrary axis.

    Parameters

    axis*The rotation axis.
    angle*
    number
    The rotation angle in radians.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    makeScale(x, y, z)

    Set this matrix to a scale matrix.

    Parameters

    x*
    number
    The x scale.
    y*
    number
    The y scale.
    z*
    number
    The z scale.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    lookAt(eye, target, up)

    Set this matrix to a look-at matrix.

    Parameters

    eye*The eye position.
    target*The target position.
    up*The up vector.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    compose(position, quaternion, scale)

    Compose this matrix from position, quaternion and scale.

    Parameters

    position*The position.
    quaternion*The rotation quaternion.
    scale*The scale.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    decompose(position, quaternion, scale)

    Decompose this matrix into position, quaternion and scale.

    Parameters

    position*The output position.
    quaternion*The output rotation quaternion.
    scale*The output scale.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    transformPoint(pt)

    Transform a point by this matrix.

    Parameters

    pt*The point to transform.
    * Required

    Returns

    typedescription
    Vector3 The transformed point.

    transformDirection(v)

    Transform a direction vector by this matrix.

    Parameters

    v*The direction vector to transform.
    * Required

    Returns

    typedescription
    Vector3 The transformed direction vector.

    equals(matrix)

    Check if this matrix equals another matrix.

    Parameters

    matrix*The matrix to compare.
    * Required

    Returns

    typedescription
    boolean True if the matrices are equal.

    fromArray(array)

    Set this matrix from an 16 element array.

    Parameters

    array*
    Array.<number>
    The source array.
    * Required

    Returns

    typedescription
    Matrix4 A reference to this matrix.

    toArray()

    Convert this matrix to an 16 element array.

    Returns

    typedescription
    Array.<number> The array containing the matrix elements.

    clone()

    Create a clone of this matrix.

    Returns

    typedescription
    Matrix4 A new matrix with the same components.

    getRotationMatrixAligningVectors(from, to, epsilon)

    Computes a rotation matrix that aligns direction vector from onto to.

    Parameters

    from*Source direction vector.
    to*Target direction vector.
    epsilon
    number
    Tolerance used for parallelism checks.
    * Required

    Returns

    typedescription
    Matrix4
    • A rotation-only matrix (no translation).