Sign in to follow this  
Ratman

Terrain/Projectile Collision

Recommended Posts

Trying to do collision response with a projectile and terrain. Say I have the terrain's surface normal where the collision took place (N) and I have a velocity vector of the projectile (V). I just need to reflect V across N (reflection = incidence). BUT Im thinking I can do with this without even looking at the angle and just get away with vector addition. Something like V = (V + (N*2) should work right? (assuming V is pointing in the direction the ball is moving, not pointing towards where the projectile came from). It looks close but not quite right in the game. I'm on no sleep right now and just wanted to "bounce" it off you guys :) Any suggestions? Thanks Ratman

Share this post


Link to post
Share on other sites
Quote:
Something like V = (V + (N*2) should work right?


Pretty close. Try:

V = V - 2 * V.Dot(N) * N

Share this post


Link to post
Share on other sites
That looks right, thanks. Can anyone explain this a little more for me? I'm working it out on paper and it looks good but something just isnt clicking about why this is working. Thanks

Share this post


Link to post
Share on other sites
A picture would be best, but in lieu of that...

If N is unit-length, then V.Dot(N) is the length of the projection of V onto N.

Furthermore, V can be decomposed into two vectors, one of which is parallel to N and one of which is perpendicular.

The parallel component is:

V.Dot(N) * N

The perpendicular component is necessarily:

V - V.Dot(N) * N

Already we have a useful equation: V - V.Dot(N) * N gives us the component of a vector that is perpendicular to a plane with normal N.

Here we have subtracted from V the component of V that is parallel to N. Doing this once makes V 'flush' with the plane with normal N. Doing it twice reflects V through this plane.

Hm. Maybe not the best explanation - perhaps someone else will give it a try. But that's the general idea.

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