# How do I calculate if two moving objects will hit each other in three dimensions?

Position, speed and heading are known, and the size and shape of these objects are also known. Gravity is irrelevant, so these objects will be moving in straight lines. I tagged this with geometry and trigonometry but I'm not sure exactly where it should go.

-
This sounds very much like a problem in programming (in part, at least) - if so, I would suggest that you do a google search for "collision detection". Here is one page that might be helpful: euclideanspace.com/threed/animation/collisiondetect/index.htm – Martin Wanvik Apr 3 '12 at 15:40
If you didn't already do this, drawing a picture and the relevant data may help. – john w. Apr 3 '12 at 20:07

## 1 Answer

It depends on the shape of those objects. What is it ? Here is an answer assuming they are spheres.

If $x_1(t)$ and $x_2(t)$ are the positions of the centers of both objects at time $t$ (assumed to be spherical, of radii $R_1$ and $R_2$) then they will collide if and only if there is a $t$ such that $|x_1(t)-x_2(t)|<R_2+R_1$. (equation E)

If they are moving at constant speed $v_1$ and $v_2$, starting at initial positions $x_1^0$ and $x_2^0$ then this is achived iff $|x_1^0 - x2^0 + t (v_1-v_2)| < R_2 + R_1$ has a solution for $t$ (it's a simple system of three inequalities).

Now if your objects are not spherical, the problem is more complicated (for example, they can spin). But if object one is contained within a sphere of radius $R_1$ (the same with object 2 and $R_2$) you can say that if (E) has no solution then they won't collide, and if your objects contain spheres of radii $r_1$ and $r_2$, then if (E) with $r_1$ and $r_2$ has a solution, they will collide.

-
Calculating the shape of these objects is a question unto itself. Spheres are a good approximation for now though. – Garzahd Apr 3 '12 at 15:54