Chapter 1: Collision Prediction between objects moving at linear speed
Version 1: Assuming objects have sphere bounding volumes
Proof of concept:
Given two spheres s1,s2 moving at velocities v1 and v2.
By subtracting velocity v2 from both spheres, we will get sphere s1 moving relatively to s2 with speed of (v1-v2), and a static non moving sphere s2. Since v2-v2 = 0
If we move a sphere in the direction of its velocity, the shape that contains the sphere at any point in time is a capsule. Thus if the capsule for s1 intersects s2, a collision will/had occurred. The time till impact is calculated by dividing the distance of s1 and point on line s1+v1*x closest to s2 by the relative speed of s1. [Conveniently, this distance is already calculated when checking the intersection of the capsule with sphere].
Examples with 200 spheres:
- They stop moving on collision
- Bounce on collision