Optionalx: numberOptionaly: numberReadonlyisProtectedlastProtectedpageProtectedpageIterating through a Vector2 instance will yield its components (x, y) in the corresponding order.
Adds v to this vector.
Adds the scalar value s to this vector's x and y values.
Adds the multiple of v and s to this vector.
Sets this vector to a + b.
computes the angle in radians with respect to the positive x-axis
Returns the angle between this vector and vector Vector2 | v in radians.
Multiplies this vector (with an implicit 1 as the 3rd component) by m.
The x and y components of the vector are rounded up to the nearest integer value.
If this vector's x or y value is greater than the max vector's x or y value, it is replaced by the corresponding value. If this vector's x or y value is less than the min vector's x or y value, it is replaced by the corresponding value.
the minimum x and y values.
the maximum x and y values in the desired range.
If this vector's length is greater than the max value, it is replaced by the max value. If this vector's length is less than the min value, it is replaced by the min value.
the minimum value the length will be clamped to.
the maximum value the length will be clamped to.
ProtectedclampIf this vector's x or y values are greater than the max value, they are replaced by the max value. If this vector's x or y values are less than the min value, they are replaced by the min value.
the minimum value the components will be clamped to.
the maximum value the components will be clamped to.
Returns a new Vector2 instance with the same x and y values.
Copies value of v to this vector.
Computes cross product of this vector and v.
Computes distance of this vector to v.
Computes squared distance of this vector to v.
Divides this vector by v.
Divides this vector by scalar s. Set vector to ( 0, 0 ) if s == 0.
Computes dot product of this vector and v.
Checks for strict equality of this vector and v.
The components of the vector are rounded down to the nearest integer value.
Sets this vector's x and y value from the provided array or array-like.
the source array or array-like.
Optionaloffset: number(optional) offset into the array. Default is 0.
Sets this vector's x and y values from the attribute.
the source attribute.
index in the attribute.
Gets a component of this vector.
Computes length of this vector.
Computes squared length of this vector.
Linearly interpolates between this vector and v, where alpha is the distance along the line - alpha = 0 will be this vector, and alpha = 1 will be v.
vector to interpolate towards.
interpolation factor in the closed interval [0, 1].
Sets this vector to be the vector linearly interpolated between v1 and v2 where alpha is the distance along the line connecting the two vectors - alpha = 0 will be v1, and alpha = 1 will be v2.
the starting vector.
vector to interpolate towards.
interpolation factor in the closed interval [0, 1].
Computes the Manhattan length (distance) from this vector to the given vector v
see Taxicab Geometry
Computes the Manhattan length of this vector.
see Taxicab Geometry
If this vector's x or y value is less than v's x or y value, replace that value with the corresponding max value.
If this vector's x or y value is greater than v's x or y value, replace that value with the corresponding min value.
Multiplies this vector by v.
Multiplies this vector by scalar s.
Inverts this vector.
Normalizes this vector.
Sets this vector's x and y from Math.random
Rotates the vector around center by angle radians.
the point around which to rotate.
the angle to rotate, in radians.
The components of the vector are rounded to the nearest integer value.
The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value.
Sets value of this vector.
Sets a component of this vector.
Normalizes this vector and multiplies it by l.
Sets the x and y values of this vector both equal to scalar.
Sets X component of this vector.
Sets Y component of this vector.
Subtracts v from this vector.
Subtracts s from this vector's x and y components.
Sets this vector to a - b.
Returns an array [x, y], or copies x and y into the provided array.
Optionalarray: number[](optional) array to store the vector to. If this is not provided, a new array will be created.
Optionaloffset: number(optional) optional offset into the array.
The created or provided array.
Returns an array [x, y], or copies x and y into the provided array.
Optionalarray: Vector2Tuple(optional) array to store the vector to. If this is not provided, a new array will be created.
Optionaloffset: 0(optional) optional offset into the array.
The created or provided array.
Copies x and y into the provided array-like.
array-like to store the vector to.
Optionaloffset: number(optional) optional offset into the array.
The provided array-like.
Default