From 00c01a985a38fc4a6379ce84b23c87dd71b47a5f Mon Sep 17 00:00:00 2001 From: Landon Manning Date: Fri, 16 Jan 2015 03:54:41 -0500 Subject: [PATCH] Fixed consistancy --- modules/vec2.lua | 10 +++++----- modules/vec3.lua | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/vec2.lua b/modules/vec2.lua index 8d0f281..aa97cb3 100644 --- a/modules/vec2.lua +++ b/modules/vec2.lua @@ -138,7 +138,7 @@ function vector:rotate_inplace(phi) return self end -function vector:rotated(phi) +function vector:rotate(phi) local c, s = cos(phi), sin(phi) return new(c * self.x - s * self.y, s * self.x + c * self.y) end @@ -147,14 +147,14 @@ function vector:perpendicular() return new(-self.y, self.x) end -function vector:projectOn(v) +function vector:project_on(v) assert(isvector(v), "invalid argument: cannot project vector on " .. type(v)) -- (self * v) * v / v:len2() local s = (self.x * v.x + self.y * v.y) / (v.x * v.x + v.y * v.y) return new(s * v.x, s * v.y) end -function vector:mirrorOn(v) +function vector:mirror_on(v) assert(isvector(v), "invalid argument: cannot mirror vector on " .. type(v)) -- 2 * self:projectOn(v) - self local s = 2 * (self.x * v.x + self.y * v.y) / (v.x * v.x + v.y * v.y) @@ -174,14 +174,14 @@ function vector:trim_inplace(maxLen) return self end -function vector:angleTo(other) +function vector:angle_to(other) if other then return atan2(self.y, self.x) - atan2(other.y, other.x) end return atan2(self.y, self.x) end -function vector:trimmed(maxLen) +function vector:trim(maxLen) return self:clone():trim_inplace(maxLen) end diff --git a/modules/vec3.lua b/modules/vec3.lua index 509fef2..d364006 100644 --- a/modules/vec3.lua +++ b/modules/vec3.lua @@ -147,7 +147,7 @@ function vector:normalize() return self:clone():normalize_inplace() end -function vector:rotated(phi, axis) +function vector:rotate(phi, axis) if axis == nil then return self end local u = axis:normalize() or Vector(0,0,1) -- default is to rotate in the xy plane @@ -221,7 +221,7 @@ function vector:angle_between(other) return 0 end -function vector:trimmed(maxLen) +function vector:trim(maxLen) return self:clone():trim_inplace(maxLen) end