Alias for y.
Alias for x.
Add v to this vector.
Input one 2d vector
Return this vector
Add the scalar value s to this vector's x and y values.
Input one scalar value
Return this vector
Add the multiple of v and s to this vector.
Input one 2d vector
Input one scalar value
Return this vector
Set this vector to a + b.
Input one 2d vector
Input one 2d vector
Return this vector
Return the angle between this vector and vector v in radians.
Input one 2d vector
Return the angle between this vector and vector v in radians.
Multiply this vector (with an implicit 1 as the 3rd component) by m.
Input one 3x3 matrix
Return this vector
The x and y components of this vector are rounded up to the nearest integer value.
Return this vector
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.
Input the minimum x and y values
Input 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.
Input the minimum value the length will be clamped to
Input the maximum value the length will be clamped to
Return this vector
If 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.
Input the minimum value the components will be clamped to
Input the maximum value the length will be clamped to
Return this vector
Return a new 2d vector with the same x and y values as this one.
Return the cloned vector
Copy the values of the passed vector's x and y properties to this vector.
Input one 2d vector
Return this vector
Calculate the cross product of this vector and v. Note that a 'cross-product' in 2D is not well-defined. This function computes a geometric cross-product often used in 2D graphics.
Input one 2d vector
Return the cross product of this vector and v.
Compute the distance from this vector to v.
Input one 2d vector
Return the distance from this vector to v.
Compute the squared distance from this vector to v. If you are just comparing the distance with another distance, you should compare the distance squared instead as it is slightly more efficient to calculate.
Input one 2d vector
Return the squared distance from this vector to v.
Divide this vector by v.
Input one 2d vector
Return this vector
Divide this vector by scalar s.
Input one scalar value
Return this vector
Calculate the dot product of this vector and v.
Input one 2d vector
Return the dot product of this vector and v.
Return true if the components of this vector and v are strictly equal; false otherwise.
Input one 2d vector to compare
Return true if the components of this vector and v are strictly equal; false otherwise.
The components of this vector are rounded down to the nearest integer value.
Return this vector
Set this vector's x value to be array[ offset ] and y value to be array[ offset + 1 ].
Input the source array.
Input (optional) offset into the array. Default is 0.
Return this vector
Compute the square of the Euclidean length (straight-line length) from (0, 0) to (x, y). If you are comparing the lengths of vectors, you should compare the length squared instead as it is slightly more efficient to calculate.
Return the square of the Euclidean length (straight-line length) from (0, 0) to (x, y)
Linearly interpolates between this vector and v, where alpha is the percent distance along the line - alpha = 0 will be this vector, and alpha = 1 will be v.
Input 2d vector to interpolate towards.
Input interpolation factor, typically in the closed interval [0, 1].
Return this vector
Sets this vector to be the vector linearly interpolated between v1 and v2 where alpha is the percent distance along the line connecting the two vectors - alpha = 0 will be v1, and alpha = 1 will be v2.
Input the starting vector.
Input vector to interpolate towards.
Input interpolation factor, typically in the closed interval [0, 1].
Compute the Manhattan distance from this vector to v.
Input one 2d vector
Return the Manhattan distance from this vector to v.
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.
Input one 2d vector
Return this vector
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.
Input one 2d vector
Return this vector
Multiply this vector by v.
Input one 2d vector
Return this vector
Multiply this vector by scalar s.
Input one scalar value
Return this vector
Invert this vector - i.e. sets x = -x and y = -y.
Return this vector
Converts this vector to a unit vector - that is, sets it equal to a vector with the same direction as this one, but length 1.
Return this vector
Set each component of this vector to a pseudo-random value between 0 and 1, excluding 1.
Return this vector
Rotate this vector around center by angle radians.
Input the point around which to rotate.
Input the angle to rotate, in radians.
Return this vector
The components of this vector are rounded to the nearest integer value.
Return this vector
The components of this vector are rounded towards zero (up if negative, down if positive) to an integer value.
Return this vector
Sets the x and y components of this vector.
Input x component of this vector
Input y component of this vector
Return this vector
If index equals 0 set x to value. If index equals 1 set y to value
0 or 1.
Input one number
Return this vector
Sets this vector to a vector with the same direction as this one, but length l.
Input one sclar value
Return this vector
Set the x and y values of this vector both equal to scalar.
Input one scalar value
Return this vector
Replace this vector's x value with x.
Input new value of x component of this vector
Return this vector
Replace this vector's y value with y.
Input new value of y component of this vector
Return this vector
Subtract v from this vector.
Input one 2d vector
Return this vector
Subtract s from this vector's x and y components.
Input one scalar value
Return this vector
Sets this vector to a - b.
Input one 2d vector
Input one 2d vector
Return this vector
Return an array [x, y], or copies x and y into the provided array.
Input (optional) array to store this vector to. If this is not provided, a new array will be created.
Input (optional) optional offset into the array.
Return an array [x, y], or copies x and y into the provided array.
The class representing a 2d vector.