class Vector2
Creates a new Vector2 from the passed x and y coordinates.
Name | Type | Description | |
---|---|---|---|
x | number | ||
y | number |
Returns a string with the Vector2 coordinates.
Returns the string "Vector2"
Returns the Vector2 hash code as a number.
Sets the Vector2 coordinates in the passed array or Float32Array from the passed index.
Returns the Vector2.
Name | Type | Description | |
---|---|---|---|
array | FloatArray | ||
optional | index | number |
Returns a new array with 2 elements : the Vector2 coordinates.
Sets the Vector2 coordinates with the passed Vector2 coordinates.
Returns the updated Vector2.
Name | Type | Description | |
---|---|---|---|
source | Vector2 |
Sets the Vector2 coordinates with the passed floats.
Returns the updated Vector2.
Name | Type | Description | |
---|---|---|---|
x | number | ||
y | number |
Sets the Vector2 coordinates with the passed floats.
Returns the updated Vector2.
Name | Type | Description | |
---|---|---|---|
x | number | ||
y | number |
Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates.
Name | Type | Description | |
---|---|---|---|
otherVector | Vector2 |
Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates.
Returns the Vector2.
Name | Type | Description | |
---|---|---|---|
otherVector | Vector2 | ||
result | Vector2 |
Set the Vector2 coordinates by adding the passed Vector2 coordinates.
Returns the updated Vector2.
Name | Type | Description | |
---|---|---|---|
otherVector | Vector2 |
Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates.
Name | Type | Description | |
---|---|---|---|
otherVector | Vector3 |
Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2.
Name | Type | Description | |
---|---|---|---|
otherVector | Vector2 |
Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates.
Returns the Vector2.
Name | Type | Description | |
---|---|---|---|
otherVector | Vector2 | ||
result | Vector2 |
Sets the current Vector2 coordinates by subtracting from it the passed one coordinates.
Returns the updated Vector2.
Name | Type | Description | |
---|---|---|---|
otherVector | Vector2 |
Multiplies in place the current Vector2 coordinates by the passed ones.
Returns the updated Vector2.
Name | Type | Description | |
---|---|---|---|
otherVector | Vector2 |
Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates.
Name | Type | Description | |
---|---|---|---|
otherVector | Vector2 |
Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates.
Returns the Vector2.
Name | Type | Description | |
---|---|---|---|
otherVector | Vector2 | ||
result | Vector2 |
Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats.
Name | Type | Description | |
---|---|---|---|
x | number | ||
y | number |
Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates.
Name | Type | Description | |
---|---|---|---|
otherVector | Vector2 |
Sets the "result" coordinates with the Vector2 divided by the passed one coordinates.
Returns the Vector2.
Name | Type | Description | |
---|---|---|---|
otherVector | Vector2 | ||
result | Vector2 |
Returns a new Vector2 with current Vector2 negated coordinates.
Multiply the Vector2 coordinates by scale.
Returns the updated Vector2.
Name | Type | Description | |
---|---|---|---|
scale | number |
Returns a new Vector2 scaled by "scale" from the current Vector2.
Name | Type | Description | |
---|---|---|---|
scale | number |
Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones.
Name | Type | Description | |
---|---|---|---|
otherVector | Vector2 |
Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon.
Name | Type | Description | |
---|---|---|---|
otherVector | Vector2 | ||
optional | epsilon | number |
Returns the vector length (float).
Returns the vector squared length (float);
Normalize the vector.
Returns the updated Vector2.
Returns a new Vector2 copied from the Vector2.
Returns a new Vector2(0, 0)
Returns a new Vector2(1, 1)
Returns a new Vector2 set from the passed index element of the passed array.
Name | Type | Description | |
---|---|---|---|
array | ArrayLike<number> | ||
optional | offset | number |
Sets "result" from the passed index element of the passed array.
Name | Type | Description | |
---|---|---|---|
array | ArrayLike<number> | ||
offset | number | ||
result | Vector2 |
Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2.
Name | Type | Description | |
---|---|---|---|
value1 | Vector2 | ||
value2 | Vector2 | ||
value3 | Vector2 | ||
value4 | Vector2 |
Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate.
Name | Type | Description | |
---|---|---|---|
value | Vector2 | ||
min | Vector2 | ||
max | Vector2 |
Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2".
Name | Type | Description | |
---|---|---|---|
value1 | Vector2 | ||
tangent1 | Vector2 | ||
value2 | Vector2 | ||
tangent2 | Vector2 |
Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
Name | Type | Description | |
---|---|---|---|
start | Vector2 | ||
end | Vector2 | ||
amount | number |
Returns the dot product (float) of the vector "left" and the vector "right".
Name | Type | Description | |
---|---|---|---|
left | Vector2 | ||
right | Vector2 |
Returns a new Vector2 equal to the normalized passed vector.
Name | Type | Description | |
---|---|---|---|
vector | Vector2 |
Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors.
Name | Type | Description | |
---|---|---|---|
left | Vector2 | ||
right | Vector2 |
Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors.
Name | Type | Description | |
---|---|---|---|
left | Vector2 | ||
right | Vector2 |
Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix.
Name | Type | Description | |
---|---|---|---|
vector | Vector2 | ||
transformation | Matrix |
Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates.
Name | Type | Description | |
---|---|---|---|
vector | Vector2 | ||
transformation | Matrix | ||
result | Vector2 |
Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
Name | Type | Description | |
---|---|---|---|
p | Vector2 | ||
p0 | Vector2 | ||
p1 | Vector2 |
Returns the distance (float) between the vectors "value1" and "value2".
Name | Type | Description | |
---|---|---|---|
value1 | Vector2 | ||
value2 | Vector2 |
Returns the squared distance (float) between the vectors "value1" and "value2".
Name | Type | Description | |
---|---|---|---|
value1 | Vector2 | ||
value2 | Vector2 |
Returns a new Vecto2 located at the center of the vectors "value1" and "value2".
Name | Type | Description | |
---|---|---|---|
value1 | Vector2 | ||
value2 | Vector2 |
Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
Name | Type | Description | |
---|---|---|---|
p | Vector2 | ||
segA | Vector2 | ||
segB | Vector2 |