Terrain/Projectile Collision

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

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 on other sites
Quote:
 Something like V = (V + (N*2) should work right?

Pretty close. Try:

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

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 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.

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

• 14
• 23
• 11
• 11
• 9
• Forum Statistics

• Total Topics
631766
• Total Posts
3002233
×