math
Two- and three-dimensional vectors, arithmetic, and common math operations.
The standard Lua math library remains available. math.vec2.new([x, y]) and math.vec3.new([x, y, z]) construct zero vectors when called without arguments. Both expose writable components, :length(), :distance(other), :dot(other), and :normalized() (returns a copy; zero stays zero). Operators support a + b, a - b, vector * scalar, and vector / scalar; invalid/zero divisors raise errors. math.clamp(value, minimum, maximum) matches util.clamp. The global vec2/vec3 names remain aliases; native Vector3 results use the same type.
lua
local a = math.vec2.new(3, 4)
assert(a:length() == 5)
local p = math.vec3.new(1, 2, 3) + math.vec3.new(2, 0, 0)
local unit = p:normalized()