Class: Vector2D

Vector2D(x, y)

Models a 2D vector

Constructor

new Vector2D(x, y)

Creates a Vector
Parameters:
Name Type Description
x number The x axis scalar of the vector
y number The y axis scalar of the vector
Source:

Extends

Members

magnitude

Gets the euclidean distance (length) of this vector
Source:

magnitude

Rescales this vector to a new magnitude
Source:

radian

Converts to this vector to angular vector notation
Source:

radian

Converts this vector from angular vector notation
Source:

x

Gets the x coordinate of this point
Overrides:
Source:

y

Gets the x coordinate of this point
Overrides:
Source:

Methods

copy(point)

Copies the values of another point to this one
Parameters:
Name Type Description
point Object The point to copy to this one
Overrides:
Source:

distanceTo(point) → {number}

Calculates the distance between two points
Parameters:
Name Type Description
point Object The point to measure distance to
Overrides:
Source:
Returns:
The distance between this point and the one passed
Type
number

normalize()

Normaizes this vector. A normalized vector is one with a magnitude of 1.
Source:

rotate(x, y, direction)

Rotates this vector by another vector in a given direction
Parameters:
Name Type Description
x number The x scalar of the vector to rotate by
y number The y scalar of the vector to rotate by
direction number 1 to rotate clockwise, -1 to rotate anti-clockwise
Source:

rotateByRadians(radians)

Rotates this vector clockwise by an angle in radians
Parameters:
Name Type Description
radians number The angle to rotate by in radians
Source:

rotateByVector(vector)

Rotates this vector clockwise by another vector
Parameters:
Name Type Description
vector number The vector to rotate by
Source:

unrotateByRadians(radians)

Rotates this vector anti-clockwise by an angle in radians
Parameters:
Name Type Description
radians number The angle to rotate by in radians
Source:

unrotateByVector(vector)

Rotates this vector anti-clockwise by another vector
Parameters:
Name Type Description
vector number The vector to rotate by
Source: