开发者

Eliminating a direction from a vector

开发者 https://www.devze.com 2023-02-12 09:47 出处:网络
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...

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 ;-)


Eliminating a direction from a vector

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号