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.

    Quaternion

    new Quaternion(x, y, z, w)

    Quaternion representation of a rotation.

    Parameters

    x
    number
    The x component.
    y
    number
    The y component.
    z
    number
    The z component.
    w
    number
    The w component.

    Properties

    x
    number
    The x component.
    y
    number
    The y component.
    z
    number
    The z component.
    w
    number
    The w component.

    Methods

    set(x, y, z, w)

    Set the components of this quaternion.

    Parameters

    x*
    number
    The x component.
    y*
    number
    The y component.
    z*
    number
    The z component.
    w*
    number
    The w component.
    * Required

    Returns

    typedescription
    Quaternion A reference to this quaternion.

    copy(quaternion)

    Copy the components from another quaternion.

    Parameters

    quaternion*The quaternion to copy.
    * Required

    Returns

    typedescription
    Quaternion A reference to this quaternion.

    setFromAxisAngle(axis, angle)

    Set this quaternion from an axis and angle.

    Parameters

    axis*The axis (assumed to be normalized).
    angle*
    number
    The angle in radians.
    * Required

    Returns

    typedescription
    Quaternion A reference to this quaternion.

    setFromRotationMatrix(m)

    Set this quaternion from a rotation matrix.

    Parameters

    m*A 4x4 matrix with a pure rotation in the upper 3x3.
    * Required

    Returns

    typedescription
    Quaternion A reference to this quaternion.

    setFromUnitVectors(vFrom, vTo)

    Set this quaternion from two unit vectors.

    Parameters

    vFrom*The from vector (assumed to be normalized).
    vTo*The to vector (assumed to be normalized).
    * Required

    Returns

    typedescription
    Quaternion A reference to this quaternion.

    invert()

    Invert this quaternion.

    Returns

    typedescription
    Quaternion A reference to this quaternion.

    conjugate()

    Calculate the conjugate of this quaternion. For a normalized quaternion this is also its inverse.

    Returns

    typedescription
    Quaternion A reference to this quaternion.

    dot(v)

    Calculate the dot product of this quaternion and another.

    Parameters

    v*The other quaternion.
    * Required

    Returns

    typedescription
    number The dot product.

    lengthSq()

    Calculate the squared length of this quaternion.

    Returns

    typedescription
    number The squared length.

    length()

    Calculate the length of this quaternion.

    Returns

    typedescription
    number The length.

    normalize()

    Normalize this quaternion.

    Returns

    typedescription
    Quaternion A reference to this quaternion.

    multiply(q)

    Multiply this quaternion by another quaternion.

    Parameters

    q*The quaternion to multiply by.
    * Required

    Returns

    typedescription
    Quaternion A reference to this quaternion.

    multiplyQuaternions(a, b)

    Set this quaternion to the product of two quaternions.

    Parameters

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

    Returns

    typedescription
    Quaternion A reference to this quaternion.

    slerp(qb, t)

    Spherical linear interpolation between this quaternion and another.

    Parameters

    qb*The other quaternion.
    t*
    number
    The interpolation factor between 0 and 1.
    * Required

    Returns

    typedescription
    Quaternion A reference to this quaternion.

    slerpQuaternions(qa, qb, t)

    Linear spherical interpolation between the given quaternions. The result is stored in this quaternion.

    Parameters

    qa*The initial quaternion.
    qb*The final quaternion.
    t*
    number
    The interpolation factor in the interval [0, 1].
    * Required

    Returns

    typedescription
    Quaternion This quaternion.

    equals(quaternion)

    Check if this quaternion equals another quaternion.

    Parameters

    quaternion*The quaternion to compare.
    * Required

    Returns

    typedescription
    boolean True if the quaternions are equal.

    fromArray(array, offset)

    Set this quaternion from an array.

    Parameters

    array*
    Array.<number>
    The source array.
    offset
    number
    The offset into the array.
    * Required

    Returns

    typedescription
    Quaternion A reference to this quaternion.

    toArray(array, offset)

    Convert this quaternion to an array.

    Parameters

    array
    Array.<number>
    The target array.
    offset
    number
    The offset into the array.

    Returns

    typedescription
    Array.<number> The array [x, y, z, w].

    onChange(callback)

    Set the callback function to be called when this quaternion changes.

    Parameters

    callback*
    function
    The callback function.
    * Required

    Returns

    typedescription
    Quaternion A reference to this quaternion.

    clone()

    Create a clone of this quaternion.

    Returns

    typedescription
    Quaternion A new quaternion with the same components.

    slerp(qa, qb, qm, t)

    Static method for linear spherical interpolation between the given quaternions. The result is stored in qm.

    Parameters

    qa*The initial quaternion.
    qb*The final quaternion.
    qm*The interpolated quaternion.
    t*
    number
    The interpolation factor in the interval [0, 1].
    * Required

    Returns

    typedescription
    Quaternion qm