Lua · Variables · Helpers
vec
Small helpers for {x, y, z} vectors.
| Function | What it does |
|---|---|
vec.new([x][, y][, z]) | A new vector. Missing parts are 0. |
vec.add(a, b) | a + b. |
vec.sub(a, b) | a - b. |
vec.scale(a, s) | a * s. |
vec.dot(a, b) | Dot product. |
vec.length(a) | Length. |
vec.distance(a, b) | Distance. |
vec.normalize(a) | Same direction, length 1. A zero vector stays zero. |
#vec.new
vec.new([x][, y][, z])A new vector. Missing parts are 0.
Returns
vector
-
#vec.add
vec.add(a, b)a + b.
Returns
vector
-
#vec.sub
vec.sub(a, b)a - b.
Returns
vector
-
#vec.scale
vec.scale(a, s)a * s.
Returns
vector
-
#vec.dot
vec.dot(a, b)Dot product.
Returns
number
-
#vec.length
vec.length(a)Length.
Returns
number
-
#vec.distance
vec.distance(a, b)Distance.
Returns
number
-
#vec.normalize
vec.normalize(a)Same direction, length 1. A zero vector stays zero.
Returns
vector
-