Sign in to follow this  
thecoast47

Contact Points[2D][Edge vs Point]

Recommended Posts

I'm having problems with rotating rigid bodies because my method of finding contact points is flawed.

Sometimes the rotational velocity spikes on some rigid bodies because of incorrect contact points.

What I do currently, is find the point on the polygon the lowest along its contact normal.
The problem is that i will find two contact points and i have no idea on how to determine which contact point is the real contact point.

Here is what my code looks like for finding contacts for each polygon:

[code]
template<class Shape>
static void Find_POI(Shape * A,Vector2D MTD,Vector2D & CPmin){ //MTD is contact normal, CPmin is returning a contact point byref
float Dot[10];
Dot[0] = MTD^(*A->PointList[0]);
float Min= Dot[0];
int MinIndex = 0 ;

for(unsigned int K = 1; K < A->PointList.size(); K++){
Dot[K] = (*A->PointList[K])^MTD;
if(Dot[K] < Min){
Min = Dot[K];
MinIndex = K;
}
}
CPmin = *(A->PointList[MinIndex]);
}
[/code]

My Question is:
How do you guys find your contact points(Edge vs Point)?
Am i going in the right direction with my method or am i completely wrong?

Share this post


Link to post
Share on other sites
Can't understand - how did you get 2 contact points? In case of edge-point the projection on normal (assuming that you separate bodies from penetration) should return total 3 points - vertex of the object that penetrates and two vertices of an other object edge. In that case you should take only the first point - i.e. vertex of object that penetrates.

Share this post


Link to post
Share on other sites
[quote name='thecoast47' timestamp='1317264938' post='4867038']
My Question is:
How do you guys find your contact points(Edge vs Point)?
Am i going in the right direction with my method or am i completely wrong?
[/quote]

Take a look at my article on the physics and collision detection of an angry birds style game - scroll down a bit, I discuss generating the contact set which sounds like what you are after:

[url="http://www.wildbunny.co.uk/blog/2011/06/07/how-to-make-angry-birds-part-2/"]http://www.wildbunny.co.uk/blog/2011/06/07/how-to-make-angry-birds-part-2/[/url]

:)

Cheers, Paul.

Share this post


Link to post
Share on other sites
[quote name='wildbunny' timestamp='1317287347' post='4867110']
Take a look at my article on the physics and collision detection of an angry birds style game - scroll down a bit, I discuss generating the contact set which sounds like what you are after:
[url="http://www.wildbunny.co.uk/blog/2011/06/07/how-to-make-angry-birds-part-2/"]http://www.wildbunny...y-birds-part-2/[/url]

:)

Cheers, Paul.
[/quote]

Thanks for the article.This method makes a lot more sense than what i was doing.
*EDIT*
It worked.
Rigid bodies no longer Spin-out thanks to a proper contact finder.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this