Creates a new Vector2D.
The x component. Defaults to 0.
The y component. Defaults to 0.
The x component. Defaults to 0.
The y component. Defaults to 0.
Adds a scalar to this vector.
The scalar to add.
this
Calculates the Euclidean distance to another vector.
The other vector.
The distance.
Calculates the squared distance to another vector.
The other vector.
The squared distance.
Divides this vector by a scalar.
The scalar to divide by.
this
Calculates the dot product of this vector and another.
The other vector.
The dot product.
Calculates the Euclidean length of the vector.
The length.
Calculates the squared length of the vector.
The squared length.
Multiplies this vector by another (component-wise).
The other vector.
this
Normalizes the vector to a unit length of 1.
this
Scales the vector by a scalar value.
The scalar factor.
this
Sets the components of the vector.
The x component.
The y component.
this
Subtracts another vector from this one.
The vector to subtract.
this
A class representing a 2D vector. Data is stored as individual properties for fast access in JS engines.