Creates an instance of Vec2.
Optional
x: numberThe x coordinate (default is 0).
Optional
y: numberThe y coordinate (default is 0).
Returns a new vector with the absolute values of the components.
A new vector with absolute values.
Calculates the angle of the vector relative to the x-axis.
The angle of the vector.
Calculates the angle between two vectors.
The other vector.
The angle between the two vectors in radians.
Returns a new vector with ceiled components.
A new vector with components rounded up to the nearest integer.
Calculates the cross product of this vector with another vector.
The other vector.
The cross product result.
Calculates the distance to another point.
The other point.
The distance between the two points.
Calculates the dot product of this vector with another vector.
The other vector.
The dot product result.
Check if the vector is equal to another vector.
The vector to compare with.
True if the vectors are equal, otherwise false.
Returns a new vector with floored components.
A new vector with components rounded down to the nearest integer.
Inverts the direction of the vector.
The current instance with updated values.
Calculates the length of the vector.
The length of the vector.
Normalizes the vector to have a length of 1.
The current instance with updated values.
Rotates the vector 90 degrees counterclockwise.
The current instance with updated values.
Snaps the vector components to the nearest increment.
The increment to snap to.
A new vector with components snapped to the nearest increment.
Converts the vector to a string representation.
A string containing the vector's x and y coordinates.
Static
fromStatic
FromConverts an array of coordinate pairs into an array of Vec2 instances.
An array of [x, y] coordinate pairs.
An array of Vec2 instances.
Represents a 2D vector with x and y components.