Vector
Fields
Functions
new
This function has no parameters.
Return value
Name |
Type |
Description |
value |
Vector2 |
New instance of a Vector |
local my_vec3 = Vector.new()
new
Return value
Name |
Type |
Description |
value |
Vector2 |
New instance of a Vector |
local my_vec3 = Vector.new(1.0, 2.0, 3.0)
Length
This function has no parameters.
Return value
Name |
Type |
Description |
value |
float |
Vector length |
local vec = Vector.new(1.0, 2.0, 3.0)
local dist = vec:Length()
Length2D
This function has no parameters.
Return value
Name |
Type |
Description |
value |
float |
Vector length |
local vec = Vector.new(1.0, 2.0, 3.0)
local dist = vec:Length2D()
DistTo
Name |
Type |
Description |
origin |
Vector |
Another position |
Return value
Name |
Type |
Description |
value |
Vector2 |
Distance between self and another vector |
local my_vec = Vector.new(3.0, 2.0, 8.0)
local dest = Vector.new(6.0, 4.0, 16.0)
local length = my_vec:DistTo(dest)
Dot
Name |
Type |
Description |
origin |
Vector |
Another position |
Return value
Name |
Type |
Description |
value |
float |
Dot product of two vectors |
local my_vec = Vector.new(3.0, 2.0, 8.0)
local my_vec2 = Vector.new(4.0, 3.0, 1.0)
local dot = my_vec:Dot(my_vec2)
--Expected value for dot : ((3.0 * 4.0) + (2.0 * 3.0) + (8.0 * 1.0)) = (12 + 6 + 8) = 26
Cross
Name |
Type |
Description |
origin |
Vector |
Another position |
Return value
Name |
Type |
Description |
value |
float |
Cross product of two vectors |
local my_vec = Vector.new(3.0, 2.0, 8.0)
local my_vec2 = Vector.new(4.0, 3.0, 1.0)
local dot = my_vec:Cross(my_vec2)