Constructor
new Vector2D(xopt, yopt)
Creates a new instance of the Vector2D class.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x |
number |
<optional> |
0.0 | The x-component of the vector. |
y |
number |
<optional> |
0.0 | The y-component of the vector. |
- Source:
Extends
Members
x :number
The horizontal coordinate of the point. The default value is 0.
Type:
- number
- Inherited From:
- Source:
y :number
The vertical coordinate of the point. The default value is 0.
Type:
- number
- Inherited From:
- Source:
Methods
abs() → {rune.geom.Vector2D}
Set the vector axes values to absolute values.
- Source:
Returns:
- Type
- rune.geom.Vector2D
add(vector) → {rune.geom.Vector2D}
Adds the argument vector to this vector.
Parameters:
Name | Type | Description |
---|---|---|
vector |
rune.geom.Vector2D | The second vector. |
- Source:
Returns:
- Type
- rune.geom.Vector2D
cross(vector) → {number}
Returns the cross product of this vector by another.
Parameters:
Name | Type | Description |
---|---|---|
vector |
rune.geom.Vector2D | The second vector. |
- Source:
Returns:
- Type
- number
distance(point) → {number}
Returns the distance between the current and specified point.
Parameters:
Name | Type | Description |
---|---|---|
point |
rune.geom.Point | The specified point. |
- Inherited From:
- Source:
Returns:
- Type
- number
divide(value) → {rune.geom.Vector2D}
Divides this vector by another vector, or by a number specified as a
floating point number.
Parameters:
Name | Type | Description |
---|---|---|
value |
rune.geom.Vector2D | number | The value to divide by. |
- Source:
Returns:
- Type
- rune.geom.Vector2D
dot(vector) → {number}
Returns the dot product of this vector by another.
Parameters:
Name | Type | Description |
---|---|---|
vector |
rune.geom.Vector2D | The second vector. |
- Source:
Returns:
- Type
- number
equals(vector) → {boolean}
Determine if the specified vector is equal to the current vector.
Parameters:
Name | Type | Description |
---|---|---|
vector |
rune.geom.Vector2D | The second vector. |
- Source:
Returns:
- Type
- boolean
interpolate(point, fractionopt, outputopt) → {rune.geom.Point}
Determines a point between two specified points. The parameter fraction
determines where the new interpolated point is located relative to the two
end points.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
point |
rune.geom.Point | The second point. | |
fraction |
number |
<optional> |
The level of interpolation between the two points. |
output |
rune.geom.Point |
<optional> |
Save results to this object. |
- Inherited From:
- Source:
Returns:
The new, interpolated point.
- Type
- rune.geom.Point
magnitude(squaredopt) → {number}
Returns the magnitude (length) of this vector.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
squared |
boolean |
<optional> |
Request squared magnitude. |
- Source:
Returns:
- Type
- number
multiply(value) → {rune.geom.Vector2D}
Multiplies this vector by another vector, or by a number specified as a
floating point number.
Parameters:
Name | Type | Description |
---|---|---|
value |
rune.geom.Vector2D | number | The value to multiply by. |
- Source:
Returns:
- Type
- rune.geom.Vector2D
normalize(scaleopt) → {rune.geom.Vector2D}
Scales the line segment between (0,0) and the current vector to a set length.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
scale |
number |
<optional> |
The scaling value. |
- Source:
Returns:
- Type
- rune.geom.Vector2D
reverse() → {rune.geom.Vector2D}
Reverses this vector i.e multiplies it by -1.
- Source:
Returns:
- Type
- rune.geom.Vector2D
rotate(rads) → {rune.geom.Vector2D}
Rotates the vector with specified radians.
Parameters:
Name | Type | Description |
---|---|---|
rads |
number | Amount of rotation specified in radians. |
- Source:
Returns:
- Type
- rune.geom.Vector2D
round(n) → {rune.geom.Vector2D}
Rotates the vector by provided radians.
Parameters:
Name | Type | Description |
---|---|---|
n |
number | Number of decimals for precision. |
- Source:
Returns:
- Type
- rune.geom.Vector2D
subtract(vector) → {rune.geom.Vector2D}
Subtracts the argument vector from this vector.
Parameters:
Name | Type | Description |
---|---|---|
vector |
rune.geom.Vector2D | The second vector. |
- Source:
Returns:
- Type
- rune.geom.Vector2D
toString() → {string}
Returns a string that contains the values of the x and y coordinates.
- Overrides:
- Source:
Returns:
The string representation of the coordinates.
- Type
- string