# Class MutableVector

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

## Constructors

• #### Parameters

• ##### x: number

the X value of the Vector

• ##### y: number

the Y value of the Vector

• ##### Optionalopt_z: number

the Z value of the Vector (optional, zero is default value)

## Methods

• Adds the given GenericVector to this MutableVector.

#### Returns MutableVector

this MutableVector for chaining

• 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

• ##### point: GenericVector

vector to calculate distance to

#### 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

• ##### point: GenericVector

vector to calculate distance to

#### Returns number

distance between this point and the given point

• Divides this MutableVector by the given factor.

#### Parameters

• ##### factor: number

factor by which to divide this vector, must be greater than Vector.TINY_POSITIVE

#### Returns MutableVector

this MutableVector for chaining

#### Throws

if factor is less than Vector.TINY_POSITIVE

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

#### Parameters

• ##### vector: GenericVector

the object to compare to

#### 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

• Multiplies this MutableVector by the given factor.

#### Parameters

• ##### factor: number

factor by which to multiply this vector

#### Returns MutableVector

this MutableVector for chaining

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

#### Parameters

• ##### vector: GenericVector

the vector to compare to

• ##### Optionalopt_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

• ##### Optionalz: number

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

#### Returns MutableVector

this vector

• Modifies this MutableVector to have the same values as the given GenericVector.

#### Parameters

• ##### p: GenericVector

vector to copy from

#### Returns MutableVector

this vector

• Subtracts the given GenericVector from this MutableVector.

#### Parameters

• ##### p: GenericVector

vector to subtract

#### Returns MutableVector

difference of this vector and given vector

• Returns a new MutableVector having the same values as the input GenericVector.

#### Parameters

• ##### v: GenericVector

vector to copy

#### Returns MutableVector

a new MutableVector with the same values as the input GenericVector

Generated using TypeDoc