# What is the general approach to calculating time of impact in 3D?

Given two objects a and b moving at fixed velocities, how would you determine (a) whether they will collide at all, and if so, (b) time of impact?

(Let us assume these are spherical bodies each with different radii ar and br).

-

Let me call $\mathbf{v_a}$ and $\mathbf{v_b}$ the two fixed velocity vectors, and $\mathbf{s}_i$ the initial separation vector from the center of sphere $\mathbf{a}$ to the center of sphere $\mathbf{b}$.

I'll consider only the obvious case that the initial separation distance is larger than the sum of the two radii: $|\,\mathbf{s}_i\,|\,\gt\,R_\mathbf{a} + R_\mathbf{b}$. (Alternatively one could consider the case of one small sphere starting out inside a larger hollow sphere.)

If a collision occured (after the initial setting) then the duration $\tau_c$ (of whoever also determined the velocity vectors) from the initial setting until the collision of the two spheres satisfies $|\,\mathbf{s}_i + \tau_c (\mathbf{v_b} - \mathbf{v_a})\,| = R_\mathbf{a} + R_\mathbf{b}$.

Expanding this gives (if I did it correctly):

$\tau_c^2 \, (|\,\mathbf{v_b} - \mathbf{v_a}\,|)^2 + 2 \, \tau_c \, (\mathbf{s}_i \cdot (\mathbf{v_b} - \mathbf{v_a})) + (|\,\mathbf{s}_i\,|)^2 - (R_\mathbf{a} + R_\mathbf{b})^2 = 0$.

Now conditions on $\mathbf{v_a}$, $\mathbf{v_b}$ and $\mathbf{s}_i$ can be discussed under which this equation has a "positive" solution $\tau_c$, corresponding to requirements for a collision really having occured after the initial setting.

First off, obviously, a collision can only have occured if the velocities $\mathbf{v_a}$ and $\mathbf{v_b}$ were not equal, i.e. if the separation (vector, as well as distance) changed from the initial setting.

Consequently $|\,\mathbf{v_b} - \mathbf{v_a}\,| > 0$, and a quadratic equation of $\tau_c$ is obtained:

$\tau_c^2 + 2 \frac{(\mathbf{s}_i \cdot (\mathbf{v_b} - \mathbf{v_a}))}{(|\,\mathbf{v_b} - \mathbf{v_a}\,|)^2} \tau_c + \frac{(|\,\mathbf{s}_i\,|)^2 - (R_\mathbf{a} + R_\mathbf{b})^2}{(|\,\mathbf{v_b} - \mathbf{v_a}\,|)^2} = 0$.

The two general solutions to this equation are of course

$\tau_c := -\frac{(\mathbf{s}_i \cdot (\mathbf{v_b} - \mathbf{v_a}))}{(|\,\mathbf{v_b} - \mathbf{v_a}\,|)^2} +/- \sqrt{\left(\frac{(\mathbf{s}_i \cdot (\mathbf{v_b} - \mathbf{v_a}))}{(|\,\mathbf{v_b} - \mathbf{v_a}\,|)^2}\right)^2 - \frac{(|\,\mathbf{s}_i\,|)^2 - (R_\mathbf{a} + R_\mathbf{b})^2}{(|\,\mathbf{v_b} - \mathbf{v_a}\,|)^2}}$.

Duration $\tau_c$ is required to be "real", therefore the term under the square root must not be negative:

$\left(\frac{(\mathbf{s}_i \cdot (\mathbf{v_b} - \mathbf{v_a}))}{(|\,\mathbf{v_b} - \mathbf{v_a}\,|)^2}\right)^2\,\geq\,\frac{(|\,\mathbf{s}_i\,|)^2 - (R_\mathbf{a} + R_\mathbf{b})^2}{(|\,\mathbf{v_b} - \mathbf{v_a}\,|)^2}$.

Moreover, if a "collision with impact" is to be distinguished from "a mere touching and sliding past each other" of the two spheres then the requirement boils down to the term under the square root having to be positive, i.e. the corresponding strict inequality:

$\left(\frac{(\mathbf{s}_i \cdot (\mathbf{v_b} - \mathbf{v_a}))}{(|\,\mathbf{v_b} - \mathbf{v_a}\,|)^2}\right)^2\, > \,\frac{(|\,\mathbf{s}_i\,|)^2 - (R_\mathbf{a} + R_\mathbf{b})^2}{(|\,\mathbf{v_b} - \mathbf{v_a}\,|)^2}$.

Finally, duration $\tau_c$ is required to be positive, which can only be satisfied if

$(\mathbf{s}_i \cdot (\mathbf{v_b} - \mathbf{v_a})) < 0$.

The actual duration $\tau_c$ from the initial setting to the (first and only) collision then corresponds to the "minus sign solution" (as the positive value smaller than the "plus sign solution").

-

Consider first the problem of two point particles.

Let $x =x_0 + v_x t$ and $y=y_0+v_y t$ (everything is a vector, except $t$). Then I want $x=y$ which implies $$(v_x-v_y) t = (y_0-x_0)$$ So the criteria you want is for the vector $\delta v = v_x-v_y$ to be parallel to the vector $\delta x = y_0-x_0$. If they are not parallel, then no collision occurs. The time of the collision is $$t_c = \frac{\delta_v\cdot\delta_x}{\delta_v^2}$$

Now, if the particles have radii $r_a$ and $r_b$ then the criteria for a collision is that $|x-y|=r_a+r_b := r$. Whence $$|-\delta_x + \delta_v t| = r$$ Expanding this gives, if I didn't screw up somewhere, $$t^2 -2 t_c t + \alpha^2 = 0$$ where $\alpha = (\delta_x^2-r^2)/\delta_v^2$. The new collision time is now the solution of this equation. A real positive solution exists if $t_c^2 \geq \alpha^2$.

-

t=d/(V1+V2) There is impact if the distance between the two centers of the balls is shorter than the sum of their radii.

-
What is d, here? And are those vectors? Do you mean |V1| + |V2|? Please clarify and make explicit. –  Arcane Engineer Sep 11 '12 at 22:37