Mutable vector defines a point in 2D or 3D and can be altered after creation.

Implements

Constructors

Methods

  • Returns distance-squared between this MutableVector and another GenericVector regarding both as points in space. Computationally inexpensive because it only uses multiplication, no square root.

    Parameters

    Returns number

    distance squared between this point and the given point

  • Returns distance between this MutableVector and another GenericVector regarding both as points in space. Computationally expensive because it involves as square root.

    Parameters

    Returns number

    distance between this point and the given point

  • Returns true if and only if the other object is a GenericVector with the same values.

    Parameters

    Returns boolean

    true iff the other object is a GenericVector with the same values.

  • Returns length of this MutableVector. Note this is computationally expensive as it involves taking a square root.

    Returns number

    length of this MutableVector

  • Computationally cheap version of length which avoids the square root; returns sum of absolute value of each component x, y, z.

    Returns number

    sum of absolute value of each component x, y, z.

  • Returns length squared of this MutableVector. Computationally cheap because it only uses multiplication, no square root.

    Returns number

    length squared of this vector

  • Returns true if this MutableVector is nearly equal to another GenericVector.

    Parameters

    • vector: GenericVector

      the vector to compare to

    • Optional opt_tolerance: number

      optional tolerance for equality test

    Returns boolean

    true if the vectors are similar

  • Returns the normalized version of this MutableVector, having unit length and the same direction.

    Returns Vector

    normalized version of this MutableVector, having unit length and the same direction

    Throws

    if this MutableVector has length less than Vector.TINY_POSITIVE

  • Modifies this MutableVector to have the given values.

    Parameters

    • x: number

      the X value of the vector

    • y: number

      the Y value of the vector

    • Optional z: number

      the Z value of the vector, uses zero if not defined

    Returns MutableVector

    this vector

Generated using TypeDoc