Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Hey so i'm currently going through the wildbunny blog to learn about collision detection, but i'm a bit confused on how the vectors he's talking about come into play

QUOTED BLOG:

p = ||A-B|| – (r1+r2)

The two spheres are penetrating by distance p. We would also like the penetration vector so that we can correct the penetration once we discover it. This is the vector that moves both circles to the point where they just touch, correcting the penetration. Importantly it is not only just a vector that does this, it is the only vector which corrects the penetration by moving the minimum amount. This is important because we only want to correct the error, not introduce more by moving too much when we correct, or too little.

N = (A-B) / ||A-B||

P = N*p

Here we have calculated the normalised vector N between the two centres and the penetration vector P by multiplying our unit direction by the penetration distance.

Ok so i understand that p is the distance each circle is penetrating each other, but i don't get what exactly N and P is. it seems to me N is just the coordinates of the 3rd point of the right trianlge formed by point A and B (A-B) then being divided by the hypotenuse of that triangle or distance between A and B (||A-B||) Whats the significance of this?

Also, what is the penetration vector used for? It seems to me like a movement that one of the circles would perform to get un-penetrated.

share|improve this question

2 Answers

up vote 2 down vote accepted

I assume that A and B are the centers of the two spheres: Sa, Sb.

V = A - B is the vector that moves the center of Sa to the center of Sb: you see that A + V = B.

||A - B|| is the magnitude of V or modulus or length - as you prefere - that is the distance of the two spheres: p is how much the spheres are too close to each other.

N = V / ||A - B|| is a unit vector (length = 1) that shares the same direction of V so P = N·p si a vector that has the same direction of V and the length of p.

You don't want to move Sa toward Sb a little more so you will add P to B moving Sb far way from Sa in the right direction (N) and for the correct amount (p).

share|improve this answer

The text is a bit unclear, using the word normal incorrectly. N is the normalised vector pointing from B to A, meaning it has the same direction as B to A but length 1.

What are you trying to do by the way? The blog talks a lot of collision detection, but seemingly nothing about collision resolution, which depend on what kind of physics you'd like.

share|improve this answer
Probably he just wants to avoid a compenetration due a single frame/step motion by moving the spheres away so they are simply in touch. – FxIII Jun 27 '11 at 11:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.