mirror of
https://github.com/vrld/hump.git
synced 2024-11-23 12:24:19 +00:00
Fix #25: vector:angleTo() returns wrong angle.
This commit is contained in:
parent
cea730deac
commit
32e0aaeaa6
@ -121,7 +121,10 @@ local function trim(maxLen, x, y)
|
||||
end
|
||||
|
||||
local function angleTo(x,y, u,v)
|
||||
return atan2(y - (v or 0), x - (u or 0))
|
||||
if u and v then
|
||||
return atan2(y, x) - atan2(v, u)
|
||||
end
|
||||
return atan2(y, x)
|
||||
end
|
||||
|
||||
-- the module
|
||||
|
@ -175,8 +175,10 @@ function vector:trim_inplace(maxLen)
|
||||
end
|
||||
|
||||
function vector:angleTo(other)
|
||||
other = other or zero
|
||||
return atan2(self.y - other.y, self.x - other.x)
|
||||
if other then
|
||||
return atan2(self.y, self.y) - atan2(other.y, other.x)
|
||||
end
|
||||
return atan2(self.y, self.y)
|
||||
end
|
||||
|
||||
function vector:trimmed(maxLen)
|
||||
|
Loading…
Reference in New Issue
Block a user