Eliminating a direction from a vector
I'm programming a really simple 2D collision response algorithm (thankfully), but even the really simple geometry concepts have been baffling me. Been studying! But...
In this case, it's vectors:
If an object hits a piece of g开发者_如何学编程eometry, I want to completely eliminate that object's momentum in the direction parallel to the normal of the geometry's wall. There's no friction or bounce involved luckily, but even still I'm not sure how to find a vector that will completely negate that momentum along the normal.
Thank you in advance!
Calculate the dot product of the geometry wall normal with the velocity vector of the object. The result equals the velocity component in the direction of the wall normal. Subtract the wall normal multiplied by this result from the velocity vector to remove all velocity in that direction.
If you look for the reflection formula, there is a term there that subtracts twice the velocity in the direction of the geometry normal. Change that to 1 times and it will stop instead of bouncing. Sorry, no time for formulas ;-)
精彩评论