Chapter 1: Movement Prediction for Beginners
If you know the point of contact and especially the positions of the balls at contact, you can simply normalize the vector
normalize ( blue.position - green.position )
Now for the collision prediction itself:
In every update the gravity vector is applied to your current velocity. To get out mathematics this means
velocity(0) = initialVelocity
velocity(t+1) = velocity(t) + gravity
where t is the number of Updates that occured after the start of the calculation. Implementing this in code would look like this:
//I cheat a bit. You have to think of a smart way to copy in your language
var bluePredict = copy(blue)
while true do
//If blue is completly below green and moving downwards, we can't possible hit green anymore.
if blue.position.y+blue.radius < green.position.y-green.radius and blue.velocity.y < 0 do
//We don't actually add the whole G-Vector, but only the one applied in the update-timeframe
bluePredict.velocity = bluePredict.velocity + gravity*deltaTime;
bluePredict.position = bluePredict.position + bluePredict.velocity;
if detectCollision(bluePredict, green) do
return normalize (bluePredict.position - green.position);
Call predict and get the normalized vector back.
Warning This method does not interpolate the point of contact. Your balls will most likely intersect on collision and blue can even pass through green if blue moves fast enough. This is however a common problem of Collision detection and not easily tackled. Specify a language and/or Developmentarea (like Unity for example) and I can give you more detailed help. If you have questions about the interpolation, please feel free to comment.
Chapter 2: Interpolation for Beginners
Note: The following chapter is partially based on this document and this document.
A common problem with collission detection is, that the blue disc "penetrates" the green disc without colliding with it. Take a look at the following picture:
The blue arrow denotes both the direction and speed of the blue disc, it is also often known as velocity-vector.
The disc moves slow enough to collide with the green disc. Normal vector and Position of the collission are known good enough (Inaccuracies come because of my bad Paint.NET-Skills).
The disc moves slow enough to collide with the disc, but too fast for the correct result. For the Programm, it looks like the blue disc collided on the other side of green and it computes a wrong normal vector.
Worst case. Blue moves so fast that within one updatestep it is behind green, without triggering a collission.
So is fast movement necessarily bad? NO! At least not with caution.
What we used in chapter 1 is known as Periodic Interference Test (PIT). It has some great advantages (like speed), but also some great disadvantages (see picture).
The solution: Predicted Instant of Collision (PIC)
Please take a look at this question at stackoverflow, which describes your problem in 3D-Space (but should be easily convertible, as nobody actually cares for the size of the vector in this case.