Question about calculating a collision's impact point (2D)

Please don't post Bullet support questions here, use the above forums instead.
Trame
Posts: 1
Joined: Thu Apr 10, 2008 10:21 pm

Question about calculating a collision's impact point (2D)

Post by Trame »

I'm working on making a fairly simplistic 2D physics engine for a game - by which I mean, it doesn't have to be all that accurate so long as it looks right. But I don't really know about how to find the impact point when two objects collide (or, more importantly because the walls won't ever move, when an object collides with a wall). I've seen "impact point" and "point of collision" and so forth used a few different ways, so what I mean specifically is where the two objects first touch each other (the very instant where the corner of one object first intersects a side of the other).

I know I can "fix" the objects and prevent penetration just by moving them back a bit (the way I'm thinking about it is halving their distance from their original location [and their orientation from their original orientation] until they're no longer penetrating), and applying impulse shouldn't be too difficult. But when it comes to applying torque, I need to know where the objects first touched to calculate the radius.

This isn't too much of a problem if it happens that two sides of one object are stuck through one side of the other, because that just means a corner overlapped and I can just calculate where the corner crossed the side. But if it's more complicated, say, if one corner of each object is penetrating the other, I won't know which side got penetrated first and it would be a lot more difficult to figure out. I could keep halving the change in distance/orientation as before to make it simpler, but this only helps me if at some point before the objects are separate I have the "one corner penetrating one wall" situation - it's possible to skip over that to them not penetrating at all, in which case I still won't know where they first would have made contact.

Is there a simple way to do this? Am I approaching this whole thing the wrong way?

Thanks in advance for any help. I haven't programmed anything like this before and I'm kind of stumped.