5

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

DOSHI
  • 442
  • 2
  • 23
  • I think you can just use "if the distance between (x1,y1,z1) and (x2,y2,z2) is smaller than the sum of the two radiuses (r1+r2), then they're colliding). – EpicPandaForce Jun 16 '14 at 14:25
  • 1
    (x1,y1,z1) and (x2,y2,z2) are the initial positions, not the instantaneous position of the spheres. Also the spheres are not in contact initially as mentioned in the problem. – DOSHI Jun 16 '14 at 14:32
  • Hmm, so all you have is the acceleration and the initial coordinates, and you need to tell if there is any value of 't' at which the condition for intersection will be true. That is indeed an interesting question, I personally am not sure how to solve this problem. Upvoted for the challenge of it. – EpicPandaForce Jun 16 '14 at 14:39

3 Answers3

2

Using the given variable names:

  • The position of point 1 at time 0 is (x1,y1,z1)
  • The position of point 2 at time 0 is (x2,y2,z2)
  • The position of point 1 at time t is p1(t) = (x1,y1,z1) + 0.5 * (a1i,a1j,a1k) * t * t
  • The position of point 2 at time t is p2(t) = (x2,y2,z2) + 0.5 * (a2i,a2j,a2k) * t * t
  • The condition for an intersection at time t is | 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.

Marco13
  • 53,703
  • 9
  • 80
  • 159
  • I put my simple example ((0,0,1),(0,0,2),(0,0,1.2),(0,0,1.1)) with (r1+r2)=0.1 into WolframAlpha as `(1+0.5*1.2*x*x) - (2+0.5*1.1*x*x) - 0.1 = 0` and received an answer of `4.69042` which seems reasonable. What is WolframAlpha doing to solve this? – Dane Jun 16 '14 at 15:46
1

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.

DOSHI
  • 442
  • 2
  • 23
  • This looks like an excellent answer. Do you have any further links or information about the source of your solution? – Dane Jun 16 '14 at 16:47
0

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

Adrien
  • 273
  • 2
  • 8
  • Admittedly, it's hard to imagine this visually, and I'm not sure whether I understood your description, but I think that the point where to spheres (potentially) collide is *not necessarily* the point where their trajectories have the least distance. – Marco13 Jun 16 '14 at 15:25
  • @Marco13 is correct in his objection. As an example, imagine starting positions of 0,0,1 and 0,0,2, with respective accelerations of 0,0,1.2 and 0,0,1.1. The first sphere will eventually pass through the second, but there is no "closest" point on the two trajectory lines. You can also imagine a slight offset so that while the two lines cross, it is not at the crossing, but some point later on where the spheres collide. – Dane Jun 16 '14 at 15:33
  • @Dane Again: I'm not sure whether Adrien really *stated* that the collision happens at the closest points - for me, it sounded like this, but maybe I misunderstood it – Marco13 Jun 16 '14 at 16:20
  • Sure, you're right, I haven't thought about this possibility :/ – Adrien Jun 16 '14 at 18:10