从向量中消除方向
我正在编写一个非常简单的二维碰撞响应算法(值得庆幸的是),但即使是非常简单的几何概念也让我感到困惑。一直在学习!但是......
在这种情况下,它是矢量:
如果一个物体撞到一块几何体,我想完全消除该物体在平行于几何体壁法线的方向上的动量。幸运的是,没有涉及摩擦或弹跳,但即使如此,我仍然不确定如何找到一个矢量来完全抵消沿法线的动量。
先感谢您!
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 geometry, 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
计算几何壁法线与物体速度矢量的点积。结果等于壁法线方向上的速度分量。从速度矢量中减去壁法线乘以该结果即可消除该方向上的所有速度。
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.
如果您查找反射公式,其中有一个项可以减去几何法线方向上速度的两倍。将其更改为 1 次,它将停止而不是弹跳。抱歉,没有时间计算公式;-)
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 ;-)