# Class VectorView

A 2D vector on a plane.

_x: number = 0
_y: number = 0

## Accessors

• get size(): number
• The size (magnitude) of the Vector

#### Returns number

• set size(newLength: number): void
• Setting the size mutates the current vector

### Warning

Can be used to set the size of the vector, be very careful using this, mutating vectors can cause hard to find bugs

#### Returns void

• get x(): number
• Get the x component of the vector

#### Returns number

• set x(val: number): void
• Set the x component, THIS MUTATES the current vector. It is usually better to create a new vector.

### Warning

Be very careful setting components on shared vectors, mutating shared vectors can cause hard to find bugs

#### Returns void

• get y(): number
• Get the y component of the vector

#### Returns number

• set y(val: number): void
• Set the y component, THIS MUTATES the current vector. It is usually better to create a new vector.

### Warning

Be very careful setting components on shared vectors, mutating shared vectors can cause hard to find bugs

#### Returns void

• get Down(): Vector
• A unit vector pointing down (0, 1)

#### Returns Vector

• get Half(): Vector
• A (0.5, 0.5) vector

#### Returns Vector

• get Left(): Vector
• A unit vector pointing left (-1, 0)

#### Returns Vector

• get One(): Vector
• A (1, 1) vector

#### Returns Vector

• get Right(): Vector
• A unit vector pointing right (1, 0)

#### Returns Vector

• get Up(): Vector
• A unit vector pointing up (0, -1)

#### Returns Vector

• get Zero(): Vector
• A (0, 0) vector

## Methods

• Adds one vector to another

#### Parameters

• ##### `Optional` dest: Vector

Optionally copy the result into a provided vector

#### Returns Vector

• Adds one vector to this one modifying the original

### Warning

Be very careful using this, mutating vectors can cause hard to find bugs

#### Returns Vector

• Returns the average (midpoint) between the current point and the specified

#### Returns Vector

• Clamps the current vector's magnitude mutating it

#### Returns Vector

• Creates new vector that has the same values as the previous.

#### Returns Vector

• Performs a 2D cross product with scalar. 2D cross products with a scalar return a vector.

#### Parameters

• ##### v: number

The scalar to cross

#### Returns Vector

• Performs a 2D cross product with another vector. 2D cross products return a scalar value not a vector.

#### Parameters

• ##### v: Vector

The vector to cross

#### Returns number

• The distance to another vector. If no other Vector is specified, this will return the magnitude.

#### Parameters

• ##### `Optional` v: Vector

The other vector. Leave blank to use origin vector.

#### Returns number

• Performs a dot product with another vector

#### Parameters

• ##### v: Vector

The vector to dot

#### Returns number

• Compares this point against another and tests for equality

#### Parameters

• ##### vector: Vector

The other point to compare to

• ##### tolerance: number = 0.001

Amount of euclidean distance off we are willing to tolerate

#### Returns boolean

• Returns the normal vector to this one, same as the perpendicular of length 1

#### Returns Vector

• Rotates the current vector around a point by a certain number of degrees in radians

#### Returns Vector

• Scales a vector's by a factor of size

#### Parameters

• ##### `Optional` dest: Vector

Optionally provide a destination vector for the result

#### Returns Vector

• Scales this vector by a factor of size and modifies the original

### Warning

Be very careful using this, mutating vectors can cause hard to find bugs

#### Returns Vector

• Sets the x and y components at once, THIS MUTATES the current vector. It is usually better to create a new vector.

### Warning

Be very careful using this, mutating vectors can cause hard to find bugs

#### Returns number

• Subtracts a vector from another, if you subtract vector `B.sub(A)` the resulting vector points from A -> B

#### Parameters

• ##### v: Vector

The vector to subtract

#### Returns Vector

• Subtracts a vector from this one modifying the original

### Warning

Be very careful using this, mutating vectors can cause hard to find bugs

#### Parameters

• ##### v: Vector

The vector to subtract

#### Returns Vector

• Returns a string representation of the vector.

#### Returns Vector

• Calculates distance between two Vectors

#### Returns number

• Returns a vector of unit length in the direction of the specified angle in Radians.

#### Parameters

• ##### angle: number

The angle to generate the vector

#### Returns Vector

• Checks if vector is not null, undefined, or if any of its components are NaN or Infinity.