# Discerning edges from vertices

This topic is 4454 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have a collision detection system in place to accept n>2-sided polygons. At each frame the necessary linear algebra is done to see if the bounds of objects are intersecting. Presently I am only worried about vertex-edge collisions, and I am using the impulse equations outlined in Chris Hecker's article on the subject. One of the first things the article points out is that the difference in the velocity of the point of intersection of both objects, vAB, should always be negative. This indicates that the algorithm needs to know which object's vertex is penetrating the other object's edge. (if vA - vB < 0 then vB - vA > 0) The question I have is of how to tell which is which. I've looked over Hecker's sample code and it seems like he assumes the object the collision is being handled in has the edge and is guaranteed to be penetrated by a vertex of the other object. Only knowing the linear equations (y = mx + b, with horizontal max and min) for the edges, how can I tell which is which? It would be easy if the collision were perfectly detected with the vertex exactly on the edge, but a small amount of penetration creates two intersection points. At first glance I thought, "The object with the edge will have two intersections with the other object, and the object with the vertex will have one intersection on each of two edges." Not only does this require a bit more tracking on my part (so far I have been immediately handling collisions at each point as they're found), but it doesn't always work with n-sided polygons. One complication arises should an object's edge have multiple collisions with the same object, or if its endpoint could is a vertex in another edge-vertex collision. Any thoughts or resources would be appreciated.

##### Share on other sites
First of all, the line equation y = mx + b really shouldn't even make an appearance in the context of arbitrary 2D collision detection; you should use another representation (such as two points, or a point and a vector) instead.

I don't remember exactly how Hecker addresses collision detection in his article, but I recall it as being fairly ad hoc (the focus of the article is really on physics, not intersection detection). The algorithm that you really want to be using is the SAT (separating axis theorem), which happens to be under discussion in another currently active thread in this forum. I'd check it out, as it has a lot of useful info and some links to implementations.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633722
• Total Posts
3013547
×