Initially, two non-touching spheres of radii R1 and R2 are lying in space at rest.
Both of them are then given accelerations a1 and a2 respectively at time=0.
Find whether they will ever come in contact. Their initial positions are represented as (x1,y1,z1)
and (x2,y2,z2) respectively. Accelerations have respective components in 3D. They are
represented as (a1i,a1j,a1k) and (a2i,a2j,a2k) respectively.
What is the mathematical condition for successful collision of spheres? Or what should be the programming thinking to solve this kind of problem.
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,y1,z1,x2,y2,z2,a1i,a2i,a1j,a2j,a1k and a2k
Using the given variable names:
(x1,y1,z1)
(x2,y2,z2)
p1(t) = (x1,y1,z1) + 0.5 * (a1i,a1j,a1k) * t * t
p2(t) = (x2,y2,z2) + 0.5 * (a2i,a2j,a2k) * t * t
| p1(t) - p2(t) | < r1+r2
The | ... |
denotes the euclidean distance, that is | (x,y,z) | = sqrt(x*x+y*y+z*z)
This yields the condition:
sqrt((x1+0.5*a1i*t*t - x2+0.5*a2i*t*t)^2+
(y1+0.5*a1j*t*t - y2+0.5*a2j*t*t)^2+
(z1+0.5*a1k*t*t - z2+0.5*a2k*t*t)^2) < r1 + r2
When there is a t
where this condition is true, then the spheres touch/intersect at this point in time.
I tried to feed this into WolframAlpha and solve for t
, but did not succeed. Implementing a purely analytical solution will be hard, anyhow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With