blob: cbbba4f39626c34d23301ad0be6d47a708f2b52a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
require 'honey.std'
local values = {}
local sum = 0
function integral(value)
sum = sum + value
table.insert(values, value)
if #values > 20 then
sum = sum - values[1]
table.remove(values, 1)
end
return sum
end
local prev = 0
function derivative(value)
local delta = value - prev
prev = value
return delta
end
return function(db, self, other, point)
local tbl = ode.ContactGeomTable(point)
local x = tbl.depth - 3.8
local spring = db:getComponent(self, "spring")
spring.F = math.abs(500 * x)
print("depth", x)
end
|