开发者

What is a good way to simulate particle movement?

I am trying to simulate the following:

  • 10 balls that are moving in an area of fixed dimensions
  • Whenever two or more balls come into a proximity range of say 40m, I want an event to be triggered

My idea is to utilize a movement trace with different proper开发者_JAVA百科ties to guide the movement of the balls and study how each of these balls come into contact with each other. Can someone suggest a good way to do this?


I'm suspecting what you are looking for is collision detection and/or response algorithms. You might find this question and answer doing almost exactly the same as your scenario. For good explanation of underlying physics and math I find these old articles from Chris Hecker very useful.


For physics (moving and colliding), there's the Open Dynamics Engine which has bindings with various languages including python. I personally haven't used this but it has been used in a few commercial games.


In a normal approach what we can do is... every time on every movement in any ball, check if any ball is colliding with any other ball.

Then we can put some optimization in this approach by keeping safe distance variable between every pair of balls. Safe distance means the distance between two balls, which is available before collision. If those two balls moves by that total safe distance, no need to check if they are colliding, once the accumulation of their movement is more than safe distance, then only we will check collision and calculate safe distance for next check.

For example for your case, if two balls are 100 m far from each other then safe distance is 60 m, so we will not check collision until unless both these balls move 60m distance.

this is just my thought. others can tell better approaches.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜