Vector2 class
- Lots of helper methods
- Chaining methods
- Defined methods for +, -, *, /, ==, ~= operators
- Defined tostring method
local Vector2 = require("shard.vector2")
Creates new vector
Sets vector
Copies vector
Adds vector / number to current vector
Subrects vector / number to current vector
Multiplies vector / number to current vector
Divides vector / number to current vector
Normalizes vector
Returns vector length
Sets vector length
Returns distance to another vector
Lerps current vector to destVector by progress (0 - 1)
Rotates vector using radians
local Vector2 = require("shard/vector2")
local direction = Vector2(1, 0)
direction:rotateRad(1):add(5)
direction = direction - Vector2(0.365, 5):length()
direction:setLength(2.25)
print(direction)