Skip to main content

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

FieldDescriptionType
xThe x component of the Vec2number
yThe y component of the Vec2number

Arithmetic

OperatorDescriptionReturn
Vec2 + Vec2Returns a new Vec2 that is the sum of bothVec2
Vec2Vec2Returns the difference between bothVec2
Vec2 * numberReturns the Vec2 with each component multiplied by the numberVec2
Vec2 / numberReturns the Vec2 with each component divided by the numberVec2
Vec2Returns the negation of the Vec2Vec2

Functions

note

Make sure to use vec:function() and not vec.function(), or you'll get an error

FunctionDescriptionReturn
:magnitude()Returns the length of the Vec2number