I am trying to find the simplest way of calculating the exact instant that two spheres collide.

Each sphere has an initial position, initial velocity, acceleration and radius. I am working in 2D.

This will be used in a computer program, so I apologize if some of my math looks more like code. I am also trying to avoid using functions such as square root as they are computationally expensive.

I can get an equation that will tell me the distance between the two spheres at a given time, but I cannot re-arrange to get the time at a given distance.

After doing research on the internet I have come up with the following.

It is easier to assume that one sphere is stationary at the origin so we end up with one set of relative vectors.

relative position (rP) = sphere 2 position - sphere 1 position

relative velocity (rV) = sphere 2 velocity - sphere 1 velocity

relative acceleration (rA) = sphere 2 acceleration - sphere 1 acceleration

We can also add the two radii so we are then trying to work out when the point is sumRadii from the origin.

The distance between the two points is calculated using Pythagoras's theory.

d^2 = x^2 + y^2

From the equations of motion we know:

s = ut + 0.5at^2

therefore:

finalPosistion = initalPosition + initalvelocity*t + 0.5*acceleration*t^2

For my scenario it would be:

d^2 = (rPx + (rVx * t) + (rAx * 0.5 * t * t))^2 + (rPy + (rVy * t) + (rAy * 0.5 * t * t))^2

Assuming the spheres are not touching to start with, when d^2 = sumRadii^2 we know the spheres have collided. This means we can rearrange the equation slightly to give:

0 = (rPx + (rVx * t) + (rAx * 0.5 * t * t))^2 + (rPy + (rVy * t) + (rAy * 0.5 * t * t))^2 - sumRadii^2

As the collision time.

I have tried using both my head and derive (a maths program that has been working for 18 hours solid) to give me a function for t but I cannot figure it out.

I would be very grateful if you could help me solve the last stages of this problem.