Declare that Vector2 will have numeric properties.
Construct a new Vector2.
Initial x component of vector
Initial y component of vector
Construct a new Vector2 using component from another vector.
Construct a new Vector2.
A series of numbers
Length variable to use vector as array.
Does the vector mutate?
Set immutable and return reference to self.
Reference to self
Magnitude of vector.
Magnitude of vector.
Set mutable and return reference to self.
Reference to self
Alternative getter/setter for x component.
Alternative getter/setter for x component.
Alternative getter/setter for y component.
Alternative getter/setter for y component.
Vector2 with values: [0, -1].
Vector2 with values: [-1, 0].
Vector2 with values: [-∞, -∞].
Vector2 with values: [1, 1].
Vector2 with values: [∞, ∞].
Vector2 with values: [1, 0].
Vector2 with values: [0, 1].
Vector2 with values: [0, 0].
Ensures that the magnitude of the vector does not exceed a given length.
Numeric value
Resulting vector
Creates a new vector with identical values. Mutable state is not transferred.
Clone of vector
Returns true if x and y is zero, otherwise returns false.
Accepted deviation from 0.00 (Default: 0)
— Is target zero vector?
[Mutation] Modifies both the x and y-component of a vector using a given function.
Function used to modify
Reference to vector
[Mutation] Normalizes the vector.
Reference to vector
Get normalized version of vector.
Resulting vector
Rescale the vector to given length.
Numeric value
Resulting vector
Rotate the vector by specified amount of radians. Positive rotation is counter-clockwise.
Radians to rotate
Resulting vector
Rotate the vector counter-clockwise by an amount of 180 degrees. Resulting vector is opposite of original.
Resulting vector
Rotate the vector counter-clockwise by an amount of 270 degrees. Resulting vector is perpendicular to the original.
Resulting vector
Rotate the vector counter-clockwise by an amount of 90 degrees. Resulting vector is perpendicular to the original.
Resulting vector
Rotate the vector by specified amount of degrees. Positive rotation is counter-clockwise.
Resulting vector
Scale vector by a numeric value.
Numeric value
Resulting vector
[Mutation] Set both components of vector.
New x component of vector
New y component of vector
Reference to self
[Mutation] Set both components of vector.
Vector-like object with values on the format: [ x, y ]
Reference to self
target - this
Subtract this vector from given vector.
X component to subtract from
Y component to subtract from
Resulting vector
target - this
Subtract this vector from given vector.
Vector to to subtract from
Resulting vector
Create an array from the vector.
Array on the format: [ x, y ]
a + b
Add two values together.
Left operand
Right operand
Resulting vector
Get angle (in radians) between two vectors.
First vector
Second vector
Angle in radians
Get angle (in degrees) between two vectors.
First vector
Second vector
Angle in degrees
Get angle (in radians) between vector and [1, 0].
Target vector
Angle in radians
Get angle (in degrees) between vector and [1, 0].
Target vector
Angle in degrees
Get cross product between two vectors.
First vector
Second vector
Cross product
Get distance between two positions.
First position
Second position
Distance between positions
v / n
Divide vector by a numeric value.
Vector to divide
Numeric value
Resulting vector
Get dot product between two vectors.
First vector
Second vector
Dot product
Interpolate between two positions with given value n.
Position to interpolate from
Position to interpolate to
Value between 0 - 1 used for interpolation
Interpolated position
Rotates a vector, v1, towards a second vector, v2, based on a factor, n.
Vector to interpolate from
Vector to interpolate to
Value between 0 - 1 used for interpolation
Interpolated vector
v * n
Multiply vector by a numeric value.
Vector to multiply
Numeric value
Resulting vector
Get signed angle (in radians) between two vectors.
First vector
Second vector
Signed angle in radians
Get signed angle (in degrees) between two vectors.
First vector
Second vector
Signed angle in degrees
a - b
Subtract second vector from first vector.
Left operand
Right operand
Resulting vector
Generated using TypeDoc
Vector2 class with x and y component. Can also be used as an array with two indices, i.e. using [0] and [1].
Vector2