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.

    Vector4

    new Vector4(x, y, z, w)

    Represents a 4D vector.

    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 vector.

    Parameters

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

    Returns

    typedescription
    Vector4 A reference to this vector.

    setX(x)

    Set the x component.

    Parameters

    x*
    number
    The x component.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    setY(y)

    Set the y component.

    Parameters

    y*
    number
    The y component.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    setZ(z)

    Set the z component.

    Parameters

    z*
    number
    The z component.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    setW(w)

    Set the w component.

    Parameters

    w*
    number
    The w component.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    setComponent(index, value)

    Set a component by index.

    Parameters

    index*
    number
    The component index (0=x, 1=y, 2=z, 3=w).
    value*
    number
    The component value.
    * Required

    getComponent(index)

    Get a component by index.

    Parameters

    index*
    number
    The component index (0=x, 1=y, 2=z, 3=w).
    * Required

    Returns

    typedescription
    number The component value.

    copy(v)

    Copy the components from another vector.

    Parameters

    v*The vector to copy.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    add(v)

    Add a vector to this vector.

    Parameters

    v*The vector to add.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    addScalar(s)

    Add a scalar to each component of this vector.

    Parameters

    s*
    number
    The scalar to add.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    addVectors(a, b)

    Set this vector to the sum of two vectors.

    Parameters

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

    Returns

    typedescription
    Vector4 A reference to this vector.

    sub(v)

    Subtract a vector from this vector.

    Parameters

    v*The vector to subtract.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    subScalar(s)

    Subtract a scalar from each component of this vector.

    Parameters

    s*
    number
    The scalar to subtract.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    subVectors(a, b)

    Set this vector to the difference of two vectors.

    Parameters

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

    Returns

    typedescription
    Vector4 A reference to this vector.

    multiplyScalar(scalar)

    Multiply this vector by a scalar.

    Parameters

    scalar*
    number
    The scalar to multiply by.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    applyMatrix4(m)

    Apply a 4x4 matrix transformation to this vector.

    Parameters

    m*The matrix to apply.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    divideScalar(scalar)

    Divide this vector by a scalar.

    Parameters

    scalar*
    number
    The scalar to divide by.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    setAxisAngleFromQuaternion(q)

    Set this vector to represent an axis-angle rotation from a quaternion.

    Parameters

    q*The quaternion (assumed to be normalized).
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    setAxisAngleFromRotationMatrix(m)

    Set this vector to represent an axis-angle rotation from a rotation matrix.

    Parameters

    m*The rotation matrix (upper 3x3 assumed to be a pure rotation matrix).
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    min(v)

    Set each component to the minimum of this vector and another vector.

    Parameters

    v*The vector to compare.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    max(v)

    Set each component to the maximum of this vector and another vector.

    Parameters

    v*The vector to compare.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    clamp(min, max)

    Clamp each component of this vector between corresponding components of min and max vectors.

    Parameters

    min*The minimum values.
    max*The maximum values.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    clampScalar(minVal, maxVal)

    Clamp each component of this vector between scalar min and max values.

    Parameters

    minVal*
    number
    The minimum value.
    maxVal*
    number
    The maximum value.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    floor()

    Apply floor to each component of this vector.

    Returns

    typedescription
    Vector4 A reference to this vector.

    ceil()

    Apply ceil to each component of this vector.

    Returns

    typedescription
    Vector4 A reference to this vector.

    round()

    Apply round to each component of this vector.

    Returns

    typedescription
    Vector4 A reference to this vector.

    roundToZero()

    Round each component toward zero (floor for positive, ceil for negative).

    Returns

    typedescription
    Vector4 A reference to this vector.

    negate()

    Negate each component of this vector.

    Returns

    typedescription
    Vector4 A reference to this vector.

    dot(v)

    Calculate the dot product of this vector and another vector.

    Parameters

    v*The other vector.
    * Required

    Returns

    typedescription
    number The dot product.

    lengthSq()

    Calculate the squared length of this vector.

    Returns

    typedescription
    number The squared length.

    length()

    Calculate the length of this vector.

    Returns

    typedescription
    number The length.

    lengthManhattan()

    Calculate the Manhattan length (sum of absolute values) of this vector.

    Returns

    typedescription
    number The Manhattan length.

    normalize()

    Normalize this vector to unit length.

    Returns

    typedescription
    Vector4 A reference to this vector.

    setLength(l)

    Set the length of this vector. Zero-length vectors are left unchanged.

    Parameters

    l*
    number
    The desired length.
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    lerp(v, alpha)

    Set this vector to the linear interpolation between this vector and another vector.

    Parameters

    v*The target vector.
    alpha*
    number
    The interpolation factor (0-1).
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    lerpVectors(v1, v2, alpha)

    Set this vector to the linear interpolation between two vectors.

    Parameters

    v1*The start vector.
    v2*The end vector.
    alpha*
    number
    The interpolation factor (0-1).
    * Required

    Returns

    typedescription
    Vector4 A reference to this vector.

    equals(v)

    Check if this vector equals another vector.

    Parameters

    v*The vector to compare.
    * Required

    Returns

    typedescription
    boolean True if all components are equal.

    fromArray(array, offset)

    Set this vector from an array.

    Parameters

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

    Returns

    typedescription
    Vector4 A reference to this vector.

    toArray(array, offset)

    Convert this vector to an array.

    Parameters

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

    Returns

    typedescription
    Array.<number> The array containing the vector components.

    clone()

    Create a clone of this vector.

    Returns

    typedescription
    Vector4 A new vector with the same components.