Creates a new Vector2
The x component
The y component
StaticsharedA static Vector2 reset to (0, 0) on every access, for a result used straight away
This vector is shared and temporary. Do not store references to it.
Transforms this point by m as a 2D transform: rotation, scale and translation
The matrix's bottom row is not used, so there is no divide.
The vector the result was written into
Clamps each component of this vector between the matching components of min and max
Assumes min <= max componentwise.
The vector the result was written into
Copies x, y from the given point into this vector
The point to copy from
Computes x * v.y - y * v.x, the z of the 3D cross product with both vectors at z = 0
The sign says which way to turn from this vector to v: positive is the way +x turns toward +y
(counter-clockwise when y points up, clockwise on a pixi screen, where y points down), negative
the other way, and zero when they are parallel.
The other vector
Computes the distance from this point to v
The point to measure to
Computes the squared distance from this point to v
Cheaper than Vector2#distanceTo and enough to compare distances.
The point to measure to
Divides each component of this vector by the scalar s
The scalar to divide by
The target to write the result into, defaults to this vector
The vector the result was written into
Computes the dot product of this vector and v
For unit vectors it's the cosine of the angle between them: 1 when they point the same way, 0 at right angles and -1 when opposite.
The other vector
Checks whether x and y both match p exactly, with no tolerance
The point to compare against
Reads x, y from array starting at offset
The array to read from
The index of the first component
Computes the squared length of this vector
Cheaper than Vector2#magnitude, since it skips the square root, and enough to compare lengths.
Multiplies each component of this vector by the scalar s
The scalar to multiply by
The target to write the result into, defaults to this vector
The vector the result was written into
Negates each component of this vector, reversing its direction
The target to write the result into, defaults to this vector
The vector the result was written into
Scales this vector to unit length, keeping its direction
A zero vector stays zero.
The target to write the result into, defaults to this vector
The vector the result was written into
Rotates this vector around the origin by angle radians, turning +x toward +y
The rotation angle in radians
The target to write the result into, defaults to this vector
The vector the result was written into
Rotates this point around center by angle radians, turning +x toward +y
The vector the result was written into
Scales this vector so its length equals length, keeping its direction
A zero vector stays zero.
The target length
The target to write the result into, defaults to this vector
The vector the result was written into
Writes this vector's values into array starting at offset
Allocates a new array when one is not supplied.
The array to write into
The index to write the first component at
The array the values were written into
A point or direction in 2D, such as a UV coordinate, a screen position or stick input
Math methods change the vector they're called on and return it, so calls chain. Pass an
outpoint as the last argument to write the result there instead and leave this one as it is; Vector3 explains why to reuseoutpoints in code that runs every frame. Where a method takes a point, any pixi.jsPointDataworks, such as a pixiPointor a plain{ x, y }object.Example