- #1
jedediah
- 4
- 0
I'm trying to figure out how to calculate collision response in a simulation I'm working on. Here are the details:
The goal of the simulation is to be very precise. The simulation groups objects into shared inertial frames, independently on each axis. Collisions can happen when objects in two different inertial frames have aligned edges. Many objects can be involved in a collision, but only two inertial frames and one axis.
I can already find all the contacts and their normals (which are either 1 or -1). Some pairs of objects may be interlocked and thus have both 1 and -1 contacts. There may be cycles in the contact graph.
What I'm trying to figure out is how to calculate new velocities for all the objects. For only two objects, their shared velocity after colliding will be the sum of their prior velocities weighted by their masses. But with a network of simultaneous contacts, it seems to be more complicated.
Here is a simple example. After this collision, all objects should have velocity 2/3. But if I handle the collisions sequentially, one of the yellow objects will end up with a different velocity than the other two.
I feel like there should be a way to solve this in general, but after much tinkering it still escapes me.
- 2D
- Objects are made of axis-aligned edges and do not rotate
- Object masses are whole numbers
- Collisions are completely inelastic
- No friction
- Collision/separation times are calculated exactly
- Entirely possible for objects to have equal velocity and this is explicitly tracked
- Complex simultaneous collisions are possible
The goal of the simulation is to be very precise. The simulation groups objects into shared inertial frames, independently on each axis. Collisions can happen when objects in two different inertial frames have aligned edges. Many objects can be involved in a collision, but only two inertial frames and one axis.
I can already find all the contacts and their normals (which are either 1 or -1). Some pairs of objects may be interlocked and thus have both 1 and -1 contacts. There may be cycles in the contact graph.
What I'm trying to figure out is how to calculate new velocities for all the objects. For only two objects, their shared velocity after colliding will be the sum of their prior velocities weighted by their masses. But with a network of simultaneous contacts, it seems to be more complicated.
Here is a simple example. After this collision, all objects should have velocity 2/3. But if I handle the collisions sequentially, one of the yellow objects will end up with a different velocity than the other two.
I feel like there should be a way to solve this in general, but after much tinkering it still escapes me.
Last edited: