Constructor
new Vec2(x, y)
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | The x coordinate |
y |
number | The y coordinate |
Methods
(static) add(u, v) → {Vec2}
Adds two vectors.
Parameters:
| Name | Type | Description |
|---|---|---|
u |
Vec2 | The first vector. |
v |
Vec2 | The second vector. |
Returns:
The sum of the two vectors.
- Type
- Vec2
(static) neg(v) → {Vec2}
Negates a vector by negating both components.
Parameters:
| Name | Type | Description |
|---|---|---|
v |
Vec2 | The vector to negate. |
Returns:
The negated vector.
- Type
- Vec2
(static) scale(v, s) → {Vec2}
Scales a vector by a scaling factor.
Parameters:
| Name | Type | Description |
|---|---|---|
v |
Vec2 | The vector to scale. |
s |
number | The scaling factor. |
Returns:
The scaled vector.
- Type
- Vec2
(static) sub(u, v) → {Vec2}
Subtracts the second vector from the first vector.
Parameters:
| Name | Type | Description |
|---|---|---|
u |
Vec2 | The vector to subtract from. |
v |
Vec2 | The vector to subtract. |
Returns:
The difference of the two vectors.
- Type
- Vec2