Alternate name for the y component.
Returns the length of the vector.
Returns the squared length of the vector.
Alternate name for the x component.
x component of the vec2.
y component of the vec2.
Returns a copy of the vector with its length clamped to length.
Clamps this vector's length to length in place.
Returns a copy of this vector.
Like distance(), but returns the squared distance between vectors.
StaticdownReturns the vector (0, -1).
Sets the x and y components of this vector to scalar.
StaticleftReturns the vector (-1, 0).
StaticlerpLinearly interpolates this vector towards target by factor t in place.
StaticmaxStaticminMoves this vector towards point by magnitude in place.
Returns a copy of the vector with its length scaled to 1.
Scales this vector's length to 1 in place.
StaticoneReturns the vector (1, 1).
Projects this vector onto the plane defined by planeNormal in place.
StaticrandomGenerates a random 2D unit vector. Equivalent to a random point on a unit-radius circle.
StaticrandomGenerates a random 2D unit vector. Equivalent to a random point on a unit-radius circle.
Reflects this vector across the plane defined by planeNormal in place.
StaticrightReturns the vector (1, 0).
Returns a string representation of the vector.
Multiplies the components of this vector by scale in place.
StaticupReturns the vector (0, 1).
StaticzeroReturns the vector (0, 0).
A two dimensional vector. Vectors can only store finite numbers in the range Number.MIN_VALUE to Number.MAX_VALUE.
Example