Ball to Ball Collision - Detection and Handling

前端 未结 14 1605
逝去的感伤
逝去的感伤 2020-11-22 05:29

With the help of the Stack Overflow community I\'ve written a pretty basic-but fun physics simulator.

\"alt

14条回答
  •  误落风尘
    2020-11-22 05:43

    Well, years ago I made the program like you presented here.
    There is one hidden problem (or many, depends on point of view):

    • If the speed of the ball is too high, you can miss the collision.

    And also, almost in 100% cases your new speeds will be wrong. Well, not speeds, but positions. You have to calculate new speeds precisely in the correct place. Otherwise you just shift balls on some small "error" amount, which is available from the previous discrete step.

    The solution is obvious: you have to split the timestep so, that first you shift to correct place, then collide, then shift for the rest of the time you have.

提交回复
热议问题