Alias for the y component.
Magnitude of the vector.
Squared magnitude of the vector.
Alias for the x component.
Horizontal component of the vector.
Vertical component of the vector.
Returns the angle in radians between this vector and the given vector.
Returns a new vec2 with its length clamped to the given maximum.
Clamps the length of this vector to the given maximum in place.
Returns a new vec2 with the same x and y values.
Returns the squared distance between this vector and the given vector.
StaticdownStatic vec2 pointing in the negative y direction (0, -1).
Returns true if this vector and the given vector have equal x and y values.
Sets all components of this vector to the given scalar value.
StaticleftStatic vec2 pointing in the negative x direction (-1, 0).
StaticlerpLinearly interpolates this vector toward the target vector by the given factor in place.
StaticmaxStaticminMoves this vector toward the target by at most the given max distance in place.
Returns a new vec2 with the same direction but unit length.
Normalizes this vector to unit length in place.
StaticoneStatic vec2 with all components set to 1.
Projects this vector onto the plane defined by the given normal in place.
StaticrandomReturns a random unit vec2.
Reflects this vector off the surface defined by the given normal in place.
StaticrightStatic vec2 pointing in the positive x direction (1, 0).
Sets this vector to a random unit vector.
Sets the x and y components of this vector.
Optionalx: numberOptionaly: numberReturns a string representation of this vector.
Uniformly scales this vector by the given scalar in place.
StaticupStatic vec2 pointing in the positive y direction (0, 1).
StaticzeroStatic vec2 with all components set to 0.
2D vector with x and y components, used for 2D positions, directions, and math operations.