Vec2
Vec2 is Simulo's built-in type for 2D vectors.
Constructor
To create a Vec2, use the global vec2(x, y)
function:
local vec = vec2(5, 5);
Fields
Field | Description | Type |
---|---|---|
x | The x component of the Vec2 | number |
y | The y component of the Vec2 | number |
Arithmetic
Operator | Description | Return |
---|---|---|
Vec2 + Vec2 | Returns a new Vec2 that is the sum of both | Vec2 |
Vec2 − Vec2 | Returns the difference between both | Vec2 |
Vec2 * number | Returns the Vec2 with each component multiplied by the number | Vec2 |
Vec2 / number | Returns the Vec2 with each component divided by the number | Vec2 |
−Vec2 | Returns the negation of the Vec2 | Vec2 |
Functions
note
Make sure to use vec:function()
and not vec.function()
, or you'll get an error
Function | Description | Return |
---|---|---|
:magnitude() | Returns the length of the Vec2 | number |