How to compute negative signed distance, i.e. penetration and direction to move? It seems that now I can only get 0 distance and some non-sense points.
Code snippet is
world = WorldModel()
create.primitives.box(1, 1, 1, world=world, name='Y') #, type='GeometricPrimitive')
create.primitives.box(2, 2, 2, center=[1.4,0,0], world=world, name='Z') #, type='GeometricPrimitive')
obj1 = world.terrain(0)
obj2 = world.terrain(1)
g1 = obj1.geometry()
g2 = obj2.geometry()
vis.add("world", world)
vis.spin(float('inf'))
rst = g1.distance(g2)
print('distance is ', rst.d)
p1 = [rst.cp1[i] for i in range(3)]
p2 = [rst.cp2[i] for i in range(3)]
print(p1, p2)
print(rst.hasGradients
result is
distance is 0.0
[-0.30000000000000004, 0.5, -0.30000000000000004] [0.4, 0.5, -1.0]