# Basic collision detection and normals

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

## Recommended Posts

[font=arial, verdana, tahoma, sans-serif][size=2]Hi guys,

I've been working on basic collision detection (ball and a plane) and I can get desired results using this formula[/font]

newVelocity = I - (normal * 2 * I.dot( normal )

But this is with a hard coded value for the surface normal. My question is, in a more dynamic setting (say a ball bouncing around a room with a cube floating in the centre) where there will be multiple normals? Do i have to do something like this..

if (collides with back of cube)
normal = (0.0, 0.0, -1.0)
if (collides with bottom of cube)
normal = (0.0, -1.0, 0.0)

etc.

and then use the formula to calculate the angle of reflection?

Thanks for any help

-James

##### Share on other sites
You typically use a scene wide query. eg:

[source]
while(1)
{
Vector3 collisionNormal;
Vector3 collisionPoint;
bool result = getCollisionFromAllObjectsInScene(oldVelocity, oldPosition, collisionNormal, collisionPoint);
if(!result) break;

// resolve collision

// update position and velocity of object
}
[/source]

##### Share on other sites
So once you determine what two objects have collided, you check which normal you need to use for that particular surface?

1. 1
Rutin
24
2. 2
3. 3
JoeJ
18
4. 4
5. 5

• 38
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631707
• Total Posts
3001836
×