by jestingrabbit » Thu Jun 21, 2012 8:04 pm UTC
So, your initial condition is having the centres within radius + radius distance (with a bit of thought you can avoid squareroots here). If they're further than that away, nothing else needs doing, they don't link. This is what you already have.
One way to describe the rest of the problem is to have two planes, with particular points on the planes, and radii, specified. Planes are either parallel, intersect in a line, or coincide. If you store your planes as a normal vector, n, and a special value, v, (so that the plane is the set of points \{ x :\ x \cdot n = v\}) then you have a good basis for working out which case you're in: form the augmented matrix composed of the normal vectors as rows, and the augmented vector is just (value1, value2), then solve the system.
In the parallel case, you're done: no collision. In the coincide case, having the centres within radius + radius distance: you're... well, you tell me.
The final case is the tricky one. The distance from the line to the two centres is important: if either centre is too far away, stop, no interesection. Points on the line are describable with one parameter. If a and b are vectors, L = \{ a + tb :\ t\in R\} is a line, and this is the form that the row reduction should spit it out in. You should be able to find values for t, t1, t2 and s1, s2, which correspond to points on the line that are also on the two circles, t1 and t2 on one circle with t1<t2, s1 and s2 on the other with s1<s2. Linking corresponds to s1 < t1 < s2 < t2, or something similar (there's lots of cases here, some are already ruled out (s1 < s2 < t1< t2 etc), but there are plenty of others to think about). Note that s1< t1< t2< s2 is *not* linking. in the sense that the rings can be pulled apart, but it might be linking by some other standard.
No guarantees that this is floating point safe: lots of differences in the row reduction etc.
ameretrifle wrote:Magic space feudalism is therefore a viable idea.