Reputation: 1601
How would I get the time needed for two balls to collide when the following are all constants
initial position of both balls
initial velocity of both balls
radius of the both balls
I am doing out a few examples in Unity 3D using c# for the code. I am not asking for the code, I just would like to know what steps to take to do this (physics wise).
Any help is appreciated
Upvotes: 1
Views: 664
Reputation: 66
Assume constants for each ball are distance (d1), velocity (v1), radius (r1), start position (p1)... etc. Also assume that the balls move in a 1D world along a tape measure.
distance = velocity * time
Distance between the balls accounting for their size: distance = p1 - p2 - (r1 + r2)
Velocity is the combined velocities of the balls (V): V = v1+v2 ** note that direction matters. If they are going towards one another, they sum. Away from one another, they subtract.
So now... V * t = p1 - p2 - (r1 + r2)
time to collision is: t = [p1 - p2 - (r1 + r2)] / V
Upvotes: 3