Anuloid (Torus) x line intersection Hi,
I need calculate ray (line) intersection with torus for my ray-tracing program (I know, its to graphics, but i need math behind it).
I can solve equation of order x^4, but thats too way slow (Cardano's method). So is there better way, how to calculate this ?
Thanks
 A: If you can't avoid solving 4th degree equations, don't use complicated solutions in terms of radicals. Computing radicals is not really any more efficient than computing roots of general polynomials, so this only serves to make the problem more complicated (ignoring other problems such as casus irreducibilis). Instead, apply a suitable root-finding algorithm on the original polynomial.
A: It seems the method developed by J.J. Van Wijk,
and described in his paper, "Ray tracing objects defined by sweeping a sphere"
(Computers & Graphics, Volume 9, Issue 3, 1985, Pages 283-290) has become the standard approach.
The main idea is to avoid the exact 4th-order computation by performing a pre-test that is only 2nd-order, essentially against the shape produced by sweeping a square rather than a circle around a circle.
Then only for the rays that pierce this bounding shape do you solve the 4th-order equations.
I believe with effort you can find downloadable implementations of ray-torus intersection following
this method.  Code written by Han-Wen Nienhuys is available here (but I didn't check to see
if he follows Van Wijk).
