Reputation: 442
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
Upvotes: 5
Views: 648
Reputation: 442
Thanks a lot for helping me out. Fortunately, I found the solution. I am sharing it here for all those who are enthusiastic about this problem.
Upvotes: 1
Reputation: 273
They are spheres, so they overlap if the distance between their centers is smaller than the sum of their radius. If acceleration makes the spheres follow a straight line, it's just a matter of computing the distance between those trajectories, which in 3D is the mix product of their direction vectors and the vector that unites both of their application points (let's say, the initial position of your spheres) divided by the module of the cross product of their direction vectors. After that, you should see when the first sphere is going to be on the point which distance to the other trajectory is minimum. When done that, you just calculate the position of the second sphere at that instant and see if they overlap
Upvotes: 0
Reputation: 54659
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.
Upvotes: 2