如果你能满足以下条件:
0) All collisions are locally binary - that is to say
collisions only occur for pairs of particles, not triples etc,
1) you can predict the future time for a collision between
objects i and j from knowledge of their dynamics (assuming that no other
collision occurs first)
2) you know how to process the physics/dynamicseac of the collision
,那么你应该能够做到以下几点:
让TPQ是预测粒子p和q之间碰撞的时间,以及V p(V q)是保持每个粒子p(q)的局部动力学的结构(即其速度,位置,弹簧常数等)
对于n颗粒...
Initialise by calculating all Tpq (p,q in 1..n)
Store the n^2 values of Tpq in a Priority Queue (PQ)
repeat
extract first Tpq from the PQ
Advance the time to Tpq
process the collision (i.e. update Vp and Vq according to your dynamics)
remove all Tpi, and Tiq (i in 1..n) from the PQ
// these will be invalid now as the changes in Vp, Vq means the
// previously calculated collision of p and q with any other particle
// i might occur sooner, later or not at all
recalculate new Tpi and Tiq (i in 1..n) and insert in the PQ
until done
有一个O(N^2)初始设置成本,但重复循环应该是O(nlogn) - 拆卸和更换的成本的2n-1个无效碰撞。对于中等数量的粒子(高达数百个),这是非常有效的。它的好处是你只需要在碰撞时处理事物,而不是等间隔的时间步骤。这对于稀疏填充模拟而言尤其有效。
这似乎是一个很好的华夫饼,但是什么是关于编程语言的具体的具体问题? –
这个问题不是关于特定的编程语言,而是关于询问是否有人知道可以帮助我(和其他面临这种问题的人)处理质量弹簧结构之间的碰撞的算法或(C++)库。如果这种问题不能在这里得到解答,我很抱歉,如果有什么问题,我会很感激。 – Petipo
这就是为什么它在这里不合适。我想你应该找到一些留言板或一些描述的聊天室。那么搜索网络呢?这是寻找图书馆的好方法。 –