Fixed consistancy
This commit is contained in:
parent
503572336d
commit
00c01a985a
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user