Richard Maine wrote: >Aleksandar Donev writes: > > > It is simply a > > quadratic equation that needs to be solved, and the answer is C / > > (-B+Sqrt(B**2-A*C)) if the two spheres collide (i.e. if this result is > > nonnegative and exists). I need to be very careful that this gives a > > very accurate answer... > >In that case, perhaps a different formula would be appropriate. That >one is notorious for being numerically poor in some cases - sounds >like the kinds of cases you have. I haven't needed highly accurate >quadratic equation solutions myself, so I don't recall the details, >but I'm sure I've seen people discuss more accurate ways to compute >this in the numerically sensitive cases. > I've read somewhere that what I wrote was the better way, as opposed to the usual formula (-B+Sqrt(B**2-A*C))/A (my A and C have a factor of 2 inside), but I don't remember where I read this and what the explanation was...I would appreciate if anyone does know of such better approaches. Thanks, Aleksandar