Vectors are dead easy in Lua, no real need for a library for them, this routine rotates a vector specified as x,y,z values around an origin using Euler angles:
function Rotate3D (x, y, z, xrot, yrot, zrot)
function RotatePoint2D (x, y, Ang) -- Ang in radians
local Sa, Ca = math.sin(Ang), math.cos(Ang)
return x*Ca - y*Sa, x*Sa + y*Ca
end
local NX, NY, NZ = x, y, z
-- X
NZ, NY = RotatePoint2D (NZ, NY, -xrot)
-- Y
NX, NZ = RotatePoint2D (NX, NZ, -yrot)
-- Z
NY, NX = RotatePoint2D (NY, NX, -zrot)
return NX, NY, NZ
end
Angles have to be in radians as it compliments the quaternion library which also needs radians.
Been there, done that, got all the T-Shirts!