Represents a 2D vector with x and y components.
Creates an instance of Vec2.
Optional
The x coordinate (default is 0).
The y coordinate (default is 0).
Calculates the angle of the vector relative to the x-axis.
The angle of the vector.
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.
Rotates the vector 90 degrees counterclockwise.
Multiplies the vector by a scalar.
The scalar value to multiply by.
Static
Adds two vectors together.
The first vector.
The second vector.
A new vector representing the sum of p0 and p1.
Computes the angle between two vectors.
The starting vector.
The ending vector.
The angle between the two vectors in radians.
Converts an array of coordinate pairs into an array of Vec2 instances.
An array of [x, y] coordinate pairs.
An array of Vec2 instances.
Finds the midpoint between two vectors.
A new vector representing the midpoint between p0 and p1.
Subtracts one vector from another.
The vector to subtract from.
The vector to subtract.
A new vector representing the difference between p1 and p0.
Represents a 2D vector with x and y components.