[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Intersection of two cylinders



Chris wrote:
> 
> Henningsen wrote:
> 
> > If you've made a solid search, I would assume that there simply is no simple
> > formula. The volume is given by a double integral, and if it cannot be
> > solved by a formula you will have to numerically approximate that integral,
> > which will require substantial computation irrespective of what type of
> > numerical integration method you choose.
> 
> <snip good advise>
> 
> Thanks Peter, now I've got to make up my mind whether I can affort to do
> a fair bit of work (it only needs to be done once in several thousand
> frames) or whether I can come up with a better method for the whole thing.

I guess that for infinitely long cylinders, this is a function of two
variables - the distance of closest approach of the two centerlines and
the angle between them (as projected into the plane that's perpendicular
to that line of shortest distance).

Since both variables are nicely bounded (the angle is 0..90 degrees and
the distance is 0..sum-of-radii), you could compute a lookup table offline
using all that nasty math that you already found - and interpolate between
table entries or something.

That ought to produce pretty good results even with a fairly small table
because this is a nice, smooth function.

Of course, if you have lots of cylinders of varying radii, then you'll need
to add a third variable - the ratio of the two radii - and scale the results
from the table according to the actual radii.

I guess that it all comes down to how much precision you need and how much
memory you are prepared to burn on the lookup table.

> Why can't we have an easy to calulcate universe! :))

I guess that in parallel universes where math is easy, there are also
fundamental laws of nature that prevent CPU's from running faster
than 1MHz.   :-)

----------------------------- Steve Baker -------------------------------
Mail : <sjbaker1@airmail.net>   WorkMail: <sjbaker@link.com>
URLs : http://www.sjbaker.org
       http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
       http://prettypoly.sf.net http://freeglut.sf.net
       http://toobular.sf.net   http://lodestone.sf.net