For two circles moving linearly, it's easy enough to calculate the time of the collision: http://twobitcoder.blogspot.com/2010/04/circle-collision-detection.html
This assumes that the circles have fixed starting points, and fixed movement paths, and calculates the time of the collision.
Is it possible to do it the other way around:
Circle 1: Starting point X1,Y1 velocity VX1,VY1 (fixed starting point, fixed linear movement path), radius R1 Circle 2: Starting point X2,Y2 velocity scalar (1m/sec, etc) (fixed starting point, fixed speed, unknown direction), radius R2
Is it possible to determine the collision position of the two circles for a minimum travel time?
I.E. Circle 1 starts at 0,0 and moves at speed 1,0 (1 unit to the right per time) Circle 2 starts at 5,5 and can move 1 unit per time What would the collision position be (or the VX2,VY2 circle 2 would need to move in) in order for the 2 circles to collide at the lowest time T. Radius of both circles is 1
In this example, a solution would be somewhere around Circle 1 being at point 3,0 at time 3. The question feels fairly complex as you have unknown variables: collision point, collision time, VX2, VY2. Although VX2 and VY2 would be constrained by |VX1|+|VX2| = 1.
The reason for the question is to tell circle 2 where it should move to in order to 'catch' circle 1.
The brute force solution would be to check the position of circle 1 at every time interval, and calculate if circle 2 would collide with circle 1 if told to move to that point - but you could miss collision points of the circles were moving fast, or get a sub-optimal point, etc.
There are two keys to solving this simply:
x2
in time t
form a circle centered on x2
. These combine to tell us that the points x2(0)
, x2(T)
, the contact point and x1(T)
are all colinear.
If we draw a diagram showing this we get a single quadratic equation in t:
|| x2(0) - x1(0) - v1 t ||^2 = (r1+r2+t)^2
Which can easily be solved for t.
To get the direction for v2
we just need to use the unit vector in the direction x1(T)-x2(0)
.