summaryrefslogtreecommitdiff
path: root/obj.lua
diff options
context:
space:
mode:
Diffstat (limited to 'obj.lua')
-rw-r--r--obj.lua5
1 files changed, 3 insertions, 2 deletions
diff --git a/obj.lua b/obj.lua
index e8aa32e..5fa4c0e 100644
--- a/obj.lua
+++ b/obj.lua
@@ -203,7 +203,7 @@ function obj:energy()
end
function obj:observe_avel(o)
- return o.data.avel - self.data.avel
+ return o.data.avel - util.magnitude(self.data.vel)
end
function obj:observe_vel(o)
@@ -230,7 +230,8 @@ function obj:avel_to_accel(o, ax, ay)
return false
end
local vx, vy = unpack(self.data.vel)
- o.data.avel = self.data.avel + (math.sqrt(ave) * (avel >= 0 and 1 or -1))
+ o.data.avel =
+ util.magnitude{vx, vy} + (math.sqrt(ave) * (avel >= 0 and 1 or -1))
o.data.vel = {vx + nvx, vy + nvy}
return true
end