Convert orientation vector to a direction

This commit is contained in:
Landon Manning 2014-10-26 21:45:44 -03:00
parent 8056d12223
commit 651f99e7cf

View File

@ -221,6 +221,13 @@ function vector:trimmed(maxLen)
return self:clone():trim_inplace(maxLen)
end
function vector:orientation_to_direction()
return new(0, 1, 0)
:rotated(self.x, new(1, 0, 0))
:rotated(self.y, new(0, 1, 0))
:rotated(self.z, new(0, 0, 1))
end
-- the module
return setmetatable({new = new, isvector = isvector, zero = zero},
{__call = function(_, ...) return new(...) end})