From 651f99e7cff10f03bf7c1526790ae4dd338291c3 Mon Sep 17 00:00:00 2001 From: Landon Manning Date: Sun, 26 Oct 2014 21:45:44 -0300 Subject: [PATCH] Convert orientation vector to a direction --- cpml/vec3.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cpml/vec3.lua b/cpml/vec3.lua index 8b936ab..89d89f0 100644 --- a/cpml/vec3.lua +++ b/cpml/vec3.lua @@ -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})