7

我正在使用wikipedia 上的基本方程,通过碰撞成对的 2D 凸对象(没有旋转)来计算结果。但是,当存在依赖关系时,例如两个对象同时撞击另一个对象:

在此处输入图像描述

例如这里,当对象 1 和 2 同时击中 3 时,pair-wise 方法就失败了。根据我计算碰撞的顺序(首先是 1-3 或首先是 2-3),我会得到不同的结果。通过碰撞重复迭代仍然会给出顺序相关的结果。

我已经设置好了,所以我可以弄清楚哪些对象相互接触,所以我的代码会在计算其中一个对象时知道对象 3 正在与另一个对象发生碰撞(所以 1-3 碰撞会知道关于 2-3 碰撞,反之亦然)。我也会知道哪些边/角与什么接触。

任何解决方案都需要健壮...例如,如果设置像这两个示例一样变得更加复杂:

在此处输入图像描述

该过程需要能够处理这种情况,甚至更糟。任何可能的同时接触/冲突链。我将拥有描述它们的所有数据,因此我“只”需要知道如何解决这些系统的一般情况。我目前没有对旋转做任何事情,这简化了事情。

看起来它需要将对象分组在一起,但是由非正交边缘引起的干扰(参见最后一个带有六边形的示例)似乎会使该方法失败。

我看到了之前问过的类似问题,但从未检查过给出的答案(死胡同?)。我也不确定冲击传播将如何解决我的第一个示例,因为 C 在第一次碰撞后正在远离……那么传播什么冲击?编辑:好的,我现在看到同时碰撞和冲击传播是两个不同的想法,这就是为什么它看起来没有用。

4

3 回答 3

4

这种多接触物理的动态模拟产生了线性互补问题。有一些算法可以解决这类问题;数学与用于线性规划问题的数学有关。

解决此类问题的需求比您想象的要普遍。任何一种模糊逼真的模拟(即重力、地面和非弹性碰撞)很快就会以物体相互靠在一起而告终。准确而稳健地处理从空间动态碰撞到滑动和滚动物体,再到“块堆叠”配置的过渡,在技术上可能具有挑战性。

我建议寻找有关该主题的书籍或其他资源。您实际需要哪些技术取决于您的特定应用程序,但您可能会找到一些有用的库。

于 2013-05-07T17:31:34.743 回答
1

Depending on the order I compute the collisions (1-3 first or 2-3 first), I will get different results.

That is correct. This is due to how the physics of collisions work. Consider this simple example, using your first figure:

m_1 = m_2 = m_3
u_1 = u_2
u_3 = 0
x_1 = x_2 + d

The only difference between 1 and 2 is that 1 is closer to 3 by d. 1 hits 3 first, stops, and v_3 becomes u_1 (u is initial and v is final velocity). Because u_2 and the new v_3 are the same, both objects 2 and 3 will proceed to the right at constant velocity with a constant distance, d, between them; they will never touch. If 1 and 2 are swapped, that is, if x_2 = x_1 + d, then 2 hits 3 and stops, and 1 trails after 3 by d.

The order of the collisions matters, and treating simultaneous collisions like two successive instantaneous collisions will give conflicting results depending on the order in which the collisions are processed.

Collisions occurring truly simultaneously is often a pathological case (mathematically) and is probably not necessary to resolve correctly for a game, or even for many scientific models.

If it really is important to correctly resolve multiple elastic collisions, the math for that can be worked out, but you would need to add additional assumptions. The elastic collision of two bodies is given by conservation of momentum:

m_1 u_1 + m_2 u_2 = m_1 v_1 + m_2 v_2

and conservation of energy:

(1/2) * m_1 u_1^2 + (1/2) * m_2 u_2^2 = (1/2) * m_1 v_1^2 + (1/2) * m_2 v_2^2

Given the initial velocities of the objects, the velocities of the two objects post-collision could be found. If you wanted to modify these equations to account for a third object,

m_1 u_1 + m_2 u_2 + m_3 u_3 = m_1 v_1 + m_2 v_2 + m_3 v_3
(1/2) * m_1 u_1^2 + (1/2) * m_2 u_2^2 + (1/2) * m_3 u_3^2 = (1/2) * m_1 v_1^2 + (1/2) * m_2 v_2^2 + (1/2) * m_3 u_3^2

a third independent equation would have to be introduced. A simple constraint could be that the momentum transfers of objects 1 and 2 should be proportional to their masses:

m_1^2 (v_1 - u_1) = m_2^2 (v_2 - u_2)

This would be nice for the situation depicted in figure 1: intuitively, I would expect 1 and 2 to have the same final velocity, and this constraint would give you that. Be warned, this equation doesn't have a clear physical basis and may give strange results in other scenarios. Experiment and see what looks right.

The equations you mention on Wikipedia (the standard, quite useful, textbook equations) assume that there is an instantaneous transfer of momentum between the two objects. This is not really true for anything in real life. When one billiard ball hits another, the balls deform very slightly, and this deformation takes time; this time is on the scale of milliseconds or less and is typically negligible.

于 2013-05-07T16:36:10.660 回答
0

逐个进行单独的碰撞,但始终使用每个对象的初始速度。完成后,将每个对象的速度变化相加。

(v1_1,v3_1) = collide(u1,u3,m1,m3)
(v2_2,v3_2) = collide(u2,u3,m2,m3)
v1 = u1 + (v1_1 - u1) = v1_1
v2 = u2 + (v2_2 - u2) = u2_2
v3 = u3 + (v3_1 - u3) + (v3_2 - u3) = v3_1 + v3_2 - u3

这样,它就不会对订单敏感。

于 2013-05-07T22:33:44.240 回答