Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!apple!agate!eos!jbm From: jbm@eos.UUCP (Jeffrey Mulligan) Newsgroups: comp.graphics Subject: Re: Point within cylinder problem Message-ID: <5134@eos.UUCP> Date: 15 Sep 89 19:28:26 GMT References: <7967@medusa.cs.purdue.edu> <10423@phoenix.Princeton.EDU> Organization: NASA Ames Research Center, California Lines: 32 markv@phoenix.Princeton.EDU (Mark T Vandewettering) writes: >> Even more helpful would be something that would determine if a >>point is within a cylinder with a hemisphere at each end. This can be >>done by checking the point against a spere at each endpoint, but if >>there is a way to get this "free" I'd prefer it. [ stuff deleted ] (point is inside endcap spheres if > DotProduct(P-Base, P-Base) < radius * radius OR > DotProduct(P-Apex, P-Apex) < radius * radius >The other case is that the point is inside the cylinder. We can determine >this by projecting the point down onto the base plane, and determining >whether it is within radius of the base point. >We can do some early trimming by precomputing some stuff. Note that if either of the dot products given above is greater than (radius*radius + DotProduct(base-apex,base-apex)), then the point P cannot lie within the cylinder. -- Jeff Mulligan (jbm@aurora.arc.nasa.gov) NASA/Ames Research Ctr., Mail Stop 239-3, Moffet Field CA, 94035 (415) 694-3745