vrld / HC

General purpose collision detection library for the use with LÖVE.
http://hc.readthedocs.org/
402 stars 48 forks source link

Getting the normal of collisions. #2

Closed dannyfritz closed 12 years ago

dannyfritz commented 12 years ago

I'm not really sure how this would work to be honest since collisions are between polygons and not between vectors, but is there a way to somehow get the normal of a collision?

LauriM commented 12 years ago

I do experience problems with this issue also!

vrld commented 12 years ago

Not sure if this is what you want, but the minimum translation vector (the last two arguments of the collision callbacks) are perpendicular to one side of at least one of the colliding shapes. In case of two circles it is perpendicular to the surface of the first circle, in case of two polygons it is perpendicular to one intersecting segment of the first polygon.

dannyfritz commented 12 years ago

What I got from this: function callback(dt, shape_one, shape_two, mtv_x, mtv_y) mtv = minimum translation vector. mtv_x and mtv_y are going to end up being the norm[sic] of one of the segments that create the polygon.