# Finding point of collision (moving circles + time)

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:

• Firstly the points reachable from `x2` in time `t` form a circle centered on `x2`.
• Secondly the first moment that the circles can touch they must be touching tangentially.

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)`.

-
Michael, would you please indicate which variables are 'a', 'b', & 'c' of the quadratic? I assume the 'x' is t which we're trying to solve for. Thanks! –  Steve H Sep 19 '11 at 16:13
I've put a clearer description in PDF form here sites.google.com/site/therobotsbrain/files/… hopefully that will make things clearer (writing math on stack overflow is not easy..) –  Michael Anderson Sep 20 '11 at 2:18
thanks. much appreciated –  Steve H Sep 20 '11 at 12:36
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}