new Vector2(xopt, yopt)
todoc
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
Number |
<optional> |
0 | |
y |
Number |
<optional> |
0 |
Members
Methods
add(v) → {Vector2}
Modifies the x and y values of the vector
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector2 |
Returns:
Vector2this
addScalar(s) → {Vector2}
Modifies the x and y values of the vector by the given scalar value
Parameters:
Name | Type | Description |
---|---|---|
s |
Number |
Returns:
Vector2this
addVectors(v1, v2) → {Vector2}
Sets the x and y values of the vector to the sum of the two given vectors
Parameters:
Name | Type | Description |
---|---|---|
v1 |
Vector2 | |
v2 |
Vector2 |
Returns:
Vector2this
angleTo(v) → {Number}
Returns the angle between this and the given vector
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector2 |
Returns:
Numberceil() → {Vector2}
Sets the vector x and y values to the smallest integer greater than or equal to it's value
Returns:
Vector2this
copy(v) → {Vector2}
Copies the given vector
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector2 |
Returns:
Vector2this
cross(v) → {Number}
Returns the 2D cross product between this and the given vector
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector2 |
Returns:
NumberdistanceTo(v) → {Number}
Returns the distance between this and the given vector
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector2 |
Returns:
Numberdivide(v) → {Vector2}
Divides the x and y values of the vector by the given vector
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector2 |
Returns:
Vector2this
divideScalar(s) → {Vector2}
Divides the x and y values of the vector by the given scalar value
Parameters:
Name | Type | Description |
---|---|---|
s |
Number |
Returns:
Vector2this
dot(v) → {Number}
Returns the dot product between this and the given vector
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector2 |
Returns:
Numberequals(v) → {Boolean}
Determines if the given vector is equal to this vector
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector2 |
Returns:
Booleanfloor() → {Vector2}
Sets the vector x and y values to the largest integer less than or equal to it's value
Returns:
Vector2this
max(v) → {Vector2}
Sets the vector x and y values to the maximum from it's value and the given vector's value
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector2 |
Returns:
Vector2this
min(v) → {Vector2}
Sets the vector x and y values to the minimum from it's value and the given vector's value
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector2 |
Returns:
Vector2this
multiply(v) → {Vector2}
Multiplies the x and y values of the vector by the given vector
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector2 |
Returns:
Vector2this
multiplyScalar(s) → {Vector2}
Multiplies the x and y values of the vector by the given scalar value
Parameters:
Name | Type | Description |
---|---|---|
s |
Number |
Returns:
Vector2this
rotate(rad) → {Vector2}
Rotates the vector by a given radian
Parameters:
Name | Type | Description |
---|---|---|
rad |
Number |
Returns:
Vector2this
round() → {Vector2}
Sets the vector x and y values to the nearest integer to it's value
Returns:
Vector2this
set(x, y) → {Vector2}
Sets the x and y values of the vector
Parameters:
Name | Type | Description |
---|---|---|
x |
Number | |
y |
Number |
Returns:
Vector2this
setLength(v) → {Vector2}
Sets the length of the vector to the length of the given vector
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector2 |
Returns:
Vector2this
setX(x) → {Vector2}
Sets the x value of the vector
Parameters:
Name | Type | Description |
---|---|---|
x |
Number |
Returns:
Vector2this
setY(y) → {Vector2}
Sets the y value of the vector
Parameters:
Name | Type | Description |
---|---|---|
y |
Number |
Returns:
Vector2this
sub(v) → {Vector2}
Modifies the x and y values of the vector by the given vector
Parameters:
Name | Type | Description |
---|---|---|
v |
Vector2 |
Returns:
Vector2this
subScalar(s) → {Vector2}
Modifies the x and y values of the vector by the given scalar value
Parameters:
Name | Type | Description |
---|---|---|
s |
Number |
Returns:
Vector2this
subVectors(v1, v2) → {Vector2}
Sets the x and y values of the vector to the subtraction of the two given vectors
Parameters:
Name | Type | Description |
---|---|---|
v1 |
Vector2 | |
v2 |
Vector2 |
Returns:
Vector2this