Initialize Vec object.
X coordinate value.
Y coordinate value.
X coordinate value.
Y coordinate value.
Adds the x and y values from the provided Vec.
The Vec to add values from.
Creates a cloned copy of the Vec.
Copies the x and y values from the provided Vec.
The Vec to copy values from.
Divides the x and y values by the provided value.
The scalar value to divide by.
Gets the dot product of two Vecs.
The Vec to get dot product from.
Gets the magnitude of the Vec.
Multiplies the x and y values by the provided value.
The scalar value to multiply.
Gets the normal of the Vec.
Set the coordinates of the Vec.
X coordinate value.
Y coordinate value.
Subtracts the x and y values from the provided Vec.
The Vec to subtract values from.
Custom string representation.
String formatted as "(x, y)"
Simple 2D vector that provides vector math helpers.
Most methods are chainable.
const vector1 = new Vec(4, 8) const vector2 = Vec.from(vector1) vector1.add(vector2).multiply(3)