Collision detection between two accelerating spheres with no initial velocity? We have two non-touching spheres of radii r1 &amp; r2 are lying in space at rest. Both of them are then given accelerations a1 &amp; a2 respectively at time t=0. Find whether they will ever come in contact. Their initial positions are represented as (x1,y1,z1) &amp; (x2,y2,z2) respectively. Accelerations have respective components in 3D. They are represented as (a1i,a1j,a1k) &amp; (a2i,a2j,a2k) respectively.

What is the mathematical condition for successful collision of spheres?

Note: It would be great if you can give me the satisfying condition in terms of variables mentioned in the question i.e., r1,r2,x1,x2,x3,y1,y2,y3,a1i,a2i,a1j,a2j,a1k and a2k



What I did to solve this problem? (This is wrong attempt)

-&gt;

rel_p = [(x1-x2),(y1-y2),(z1-z2)]
rel_a = [(a1i-a2i),(a1j-a2j),(a1k-a2k)]


B = dotproduct(rel_p,rel_a) 
C = dot(rel_p,rel_p) - (R1+R2)**2

if C&lt;0:
    ans = True
else:
    if B&lt;0 == True:
       ans = True
    else:
       ans = False
if ans:
    print "YES"
else:
    print "NO"
Find both trajectories. Calculate the distance $d$ between both centers with respect to $t$. Find if there is a solution - such a $t$ that $d=r_1+r_2$.

That's the outline. You got to point out if you got specific problems with some of the steps.

EDIT:
It seems to me that your equations are a bit wrong.

First coordinate of the first sphere will be $x_1+\frac{a_{1i}t^2}{2}$ at moment $t$. So, if I call that $\vec{x}_1=(x_1,y_1,z_1)$ and similarly introduce acceleration vector, the position at $t$ will be given by $\vec{x}_1+\frac{\vec{a}_1t^2}{2}$. You should then write both these vectors and calculate the distance vector between them (just subtract). You must find length of this vector and find if there exists such a $t$ that the length is equal (or less) to $r_1+r_2$.
Rel_p = 1/2 *rel_a *cos(theta)*t^2 ------ 1;
radius(R1+R2) = 1/2*rel_a*sin(theta)*t^2 ----2

rel_a.cos(theta) = dot(rel_a,rel_p) /|rel_p|;

rel_a.sin(theta) = cross(rel_A,rel_p)/|rel_p|;

This will also help in Ad-infinitum ;)