Collision Detection between Accelerating Spheres

后端 未结 4 1826
Happy的楠姐
Happy的楠姐 2021-02-09 02:39

I am writing a physics engine/simulator which incorporates 3D space flight, planetary/stellar gravitation, ship thrust and relativistic effects. So far, it is going very well,

4条回答
  •  盖世英雄少女心
    2021-02-09 03:10

    Draw a line between the start location and end location of each sphere. If the resulting line segments intersect the spheres definitely collided at some point and some clever math can find at what time the collision occurred. Also make sure to check if the minimum distance between the segments (if they don't intersect) is ever less than 2*radius. This will also indicate a collision.

    From there you can backstep your delta time to happen exactly at collision so you can correctly calculate the forces.

    Have you considered using a physics library which already does this work? Many libraries use far more advanced and more stable (better integrators) systems for solving the systems of equations you're working with. Bullet Physics comes to mind.

提交回复
热议问题