• 10
• 9
• 13
• 10
• 18

Collision Resolving issue 2D

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

Recommended Posts

So i finally think im finally ready for rigid body dynamics now that i have a point of intersection.
I'm really excited to get started on programming my very first physics simulation.

Right now collisions look like this:
[media]
[/media]

As you can see i can find the point of intersection for edges vs points but for edge vs edge the function i use to get point of intersection returns an ambiguous point (im not sure if the video shows that but just trust me it does).

So anyway i was reading this guys Article (PART 3) on collision detection and it turns out that i need to have a center of gravity for each shape and a vector that points from the center of gravity to the point of intersection and somehow you can get a normal. The thing is, i dont even understand where the normal comes from.

The diagram in the article looks much like this:

Can someone explain to me how i get the normal?
I'm self taught and dont fully grasp the math used in these papers..

Also i'm not using matrix math to rotate the polygons because im having trouble applying matrix math to programming.
I've decided im going to rotate shapes the retarded way by storing a copy of the shape and individually change the angle of each vertex.
using:
x=distance*cos(angle + newangle) + center.X
y=distance*sin(angle + newangle)+center.Y

***********************************UPDATE***************************************
Ok I have a new problem/

For a while now , i've been updating positions of shapes by scaling my velocity vector down by a certain magnitude and then adding the vector that i scaled down with the translation vector, updating my position.
This seemed to give me decent sliding effects and the appearance of arcade physics.

to give you a better idea of how I update positions here's an example of an update function:

 void UpdatePositions(){ Vector2D velocity = getCurrentVelocity() ; Vector2D TranslationVector = getTranslationVector();//<- Vector that translates all the points that belong to the shape Velocity *= 0.9;//<-Scaling the magnitude of the velocity vector down every frame TranslationVector +=Velocity; //<-Updating position of polygon based on velocity vector } 

Up until my recent project to implement a rigid body system, this seemed to work fairly well for arcade physics.
Recently ,I've learnt that i should use something called "integration".
I looked it up on Wikipedia and youtube for more information and i was completely blown away at how difficult it looked to use integration with ANYTHING.

I have no experience with calculus and absolutely no experience with integration.
In order to add rotation to polygons, Do i NEED to learn things like:
-> verlet intergration
->Runge Kutta intergration
->euler Intergration
(sorry if i spelled them wrong)

the only tools i have (regarding math skills) to tackle this is everything I learnt in grade 11 advanced functions.
I've also taught myself vector operations but those arent too difficult to understand.

An example of how objects should rotate when im finished:
[media]
[/media]

Share on other sites
It's not clear if you know what a normal is: http://en.wikipedia.org/wiki/Surface_normal

In figure 1 of the article you referred to, he clearly shows the normal as the vector n. He also mentions in the article that you just take the normal to the edge for the edge for edge-point collisions, facing object A as a convention.

Calculating normals to a line segment: http://stackoverflow.com/questions/1243614/how-do-i-calculate-the-normal-vector-of-a-line-segment

Share on other sites

It's not clear if you know what a normal is: http://en.wikipedia..../Surface_normal

In figure 1 of the article you referred to, he clearly shows the normal as the vector n. He also mentions in the article that you just take the normal to the edge for the edge for edge-point collisions, facing object A as a convention.

Calculating normals to a line segment: http://stackoverflow...-a-line-segment

If i didn't know what a normal is i wouldn't even be able to preform sat collision and i would be here asking about that,however, that's not the case.
And i also know that if i found the normal of the edge in Figure1 I would get a vector with the same direction of vector N.

So let me reiterate my Question.
Notice in the picture i've posted.

Can i find vector N with Rap and Rbp?
What do i have to do with vectors Rap and Rbp to get Vector N?
The only vector operations I understand are : dot product, left normal, right normal, normalizing ,addding/subtracting, scaling
*EDIT*
Okay so it turns out i basically had vector N all along.
I saw that i could use the Minimum Translational Distance Vector as the normal.
I drew all vectors on the screen and it matches this image so i guess im doing it right.
I think i can now calculate torque.

Share on other sites

So let me reiterate my Question.
Notice in the picture i've posted.

Can i find vector N with Rap and Rbp?
What do i have to do with vectors Rap and Rbp to get Vector N?

The only vector operations I understand are : dot product, left normal, right normal, normalizing ,addding/subtracting, scaling

I'm pretty sure you can't use Rap and Rbp to get the normal, since I can think of ways to transform body A, and thus Rap without affecting n: rotate body A about P. n should be unaffected, but your Rap changes. Or elongate body A in either width or height with P fixed. You can see that Rap changes again, with n unaffected. This works for body B and Rbp too. Finally, if you translate body B lengthwise, Rbp changes but n must remain the same.

Hence, there really is no relation between those two vectors and the normal, except that you need them all to model the physics.

To get n, you need to use the slope of the colliding edge, as I mentioned in my last post. Is there any problem with doing it that way?

EDIT: saw your edit. The vector for the minimum translation distance should work fine.

Share on other sites
Ok I have a new problem/

For a while now , i've been updating positions of shapes by scaling my velocity vector down by a certain magnitude and then adding the vector that i scaled down with the translation vector, updating my position.
This seemed to give me decent sliding effects and the appearance of arcade physics.

to give you a better idea of how I update positions here's an example of an update function:

 void UpdatePositions(){ Vector2D velocity = getCurrentVelocity() ; Vector2D TranslationVector = getTranslationVector();//<- Vector that translates all the points that belong to the shape Velocity *= 0.9;//<-Scaling the magnitude of the velocity vector down every frame TranslationVector +=Velocity; //<-Updating position of polygon based on velocity vector } 

Up until my recent project to implement a rigid body system, this seemed to work fairly well for arcade physics.
Recently ,I've learnt that i should use something called "integration".
I looked it up on Wikipedia and youtube for more information and i was completely blown away at how difficult it looked to use integration with ANYTHING.

I have no experience with calculus and absolutely no experience with integration.
In order to add rotation to polygons, Do i NEED to learn things like:
-> verlet intergration
->Runge Kutta intergration
->euler Intergration
(sorry if i spelled them wrong)

the only tools i have (regarding math skills) to tackle this is everything I learnt in grade 11 advanced functions.
I've also taught myself vector operations but those arent too difficult to understand.

An example of how objects should rotate when im finished:
[media]
[/media]