rocinantealpha

reference / collision

contact

Where two shapes touch: a record with point, normal (the way to move the first to part them) and depth, every field 0 when they do not.

ball = { pos: { 200, 120 }, radius: 40 }floor_box = { pos: { 0, 150 }, size: { 400, 150 } }c = contact ball floor_boxprint c.normalprint c.depth

It prints

{ 0, -1 }
10

How to write it

contact a b

Gives a value.

Related