Class

# DuVector

## DuVector(components)

A class to manipulate vectors
Constructor

#### # new DuVector(components)

Constructs a new Vector
##### Parameters:
Name Type Description
`components` `Array.<Number>` The components of the vector, one number per dimension

# Methods

#### #static fromPoints(pointA, pointB) → {DuVector}

Creates a vector from two points
##### Parameters:
Name Type Description
`pointA` `Array.<Number>` The origin of the vector
`pointB` `Array.<Number>` The end of the vector
`DuVector`

#### #static unit(axis, dimensions) → {DuVector}

Creates a unit vector
##### Parameters:
Name Type Description
`axis` `Number` The unit axis
`dimensions` `Number` The number of dimensions
`DuVector`

##### Parameters:
Name Type Description
`other` `DuVector` The vector to add
The result
`DuVector`

#### # angle(other) → {Number}

Gets the angle between the two vectors
##### Parameters:
Name Type Description
`other` `DuVector`
The angle in degrees
`Number`

#### # cross(other) → {DuVector}

Cross Product
##### Parameters:
Name Type Description
`other` `DuVector`
`DuVector`

#### # dot(other) → {Number}

Dot Product
##### Parameters:
Name Type Description
`other` `DuVector` The other vector
`Number`

#### # hasOppositeDirection(other) → {Boolean}

Checks if the two vectors have an opposite direction
##### Parameters:
Name Type Description
`other` `DuVector`
`Boolean`

#### # hasSameDirection(other) → {Boolean}

Checks if the two vectors have the same direction
##### Parameters:
Name Type Description
`other` `DuVector`
`Boolean`

#### # isPerpendicular(other) → {Boolean}

Checks if the two vectors are perpendicular
##### Parameters:
Name Type Description
`other` `DuVector`
`Boolean`

#### # length() → {Number}

+The length of the vector
The length
`Number`

#### # negate() → {DuVector}

Creates the same vector in the opposite direction (scale -1)
`DuVector`

#### # normalize() → {DuVector}

Create a normalized vector (with length equal to 1)
The normalized vector
`DuVector`

#### # orientation2D(other) → {Number}

Checks the orientation of the angle between 2D vectors
##### Parameters:
Name Type Description
`other` `DuVector`
`1`: counter-clockwiser, `-1`: clockwise, `0`: aligned
`Number`

#### # orientedAngle(other) → {Number}

Gets the angle between the two 2D vectors
##### Parameters:
Name Type Description
`other` `DuVector`
`Number`

#### # projectOn(other) → {DuVector}

Projects the vector on another vector
##### Parameters:
Name Type Description
`other` `DuVector`
`DuVector`

#### # scale(factor) → {DuVector}

Scale
##### Parameters:
Name Type Description
`factor` `Number` The scale factor
The result
`DuVector`

#### # setLength(newLength) → {DuVector}

Sets a new length for the vector
##### Parameters:
Name Type Description
`newLength` `Number`
`DuVector`

#### # subtract(other) → {DuVector}

Subtraction
##### Parameters:
Name Type Description
`other` `DuVector` The vector to subtract
The result
`DuVector`