解决台球射击冲动轨迹

0to*_*bo0 10 c++ math physics billiards bulletphysics

我正在使用子弹制作游泳池模拟器,需要准确模拟人类可能的镜头.为了找到应用于母球的冲动,我使用了物体球,口袋中心和母球的位置.

常见拍摄场景http://www.poolplayers.com/wp-content/uploads/2013/03/372-TangentLine-2.jpg

在母球的运动路径类似于物体球(180度附近的击打角度)的情况下,一切正常并且物体球落入口袋中.但似乎镜头路径的角度越大,我产生的脉冲的误差范围就越大.我已经尝试了很多东西来解决这个问题:调整球的碰撞余量,扩大世界范围,关闭摩擦力和恢复原状以及许多其他因素似乎没有改变这种行为.

以下是我的代码的相关部分:

//assume p = pocket center, b = object ball center, c = cue ball center

//first find the position of the ghost ball, ie the target point of collision for the cue ball
btVector3 ghostPos = b+(b-p).normalize()*(2.0f*BALL_RADIUS);

//then use the normal between the ghostball and cue ball as the impulse, scaled by the shots total distance
btVector3 cueImpulse = (ghostPos-c).normalize()*((p.distance(b)+ghostPos.distance(c))*HIT_RATIO);

//finally apply the impulse to the cueball's center of mass (using general form of applyImpulse to later use rel_pos for english
cueBallBody->applyImpulse(cueImpulse,btVector3());
Run Code Online (Sandbox Code Playgroud)

希望这是足够的信息.我一直在努力解决这个错误的时间,现在这个我已经工作了近两年的大项目取决于解决这个问题!即使你没有看到我的代码有什么问题,但有另一种寻找冲动的策略 - 我很乐意听到它,因为我害怕我没有任何想法.

Ger*_*ell 1

如果您想做包括球旋转在内的复杂物理,那么我推荐台球类型的物理:

例子:

http://www.real-world-physicals-problems.com/physicals-of-billiards.html

http://archive.ncsa.illinois.edu/Classes/MATH198/townsend/math.html

如果您想要更简单的物理原理,我推荐 2D 的“球对球碰撞”或 3D 的“球体到球体碰撞”。在Google上快速搜索一下,你会发现很多如何实现它的例子。

例子:

http://www.hoomanr.com/Demos/Elastic2/

球与球的碰撞 - 检测和处理

时间:

我建议计算碰撞发生的时间戳。计算到该时间点(碰撞前)的所有物理量。那将是你的幽灵球位置。计算碰撞,包括球的新速度。然后计算剩余时间段(碰撞后)的所有物理量。

方向:

你所描述的对我来说实际上是有意义的(物理学方面)。如果球向上移动(如果你看一下你的图表),那么动量的传递会更加向上,你必须在方向上做一个小的补偿。正确的方法是写出碰撞时的二维速度和位置与方向的公式,然后计算出来。

更新:简单的方法:以错误的相反方向围绕碰撞球旋转幽灵球,旋转的度数与错误/距离的度数相关。