Michael T. Jones (mtj++at++babar.asd.sgi.com)
Tue, 13 Aug 1996 14:59:28 -0700
A line segment can intersect a sphere in 0, 1, or 2 points. These
cases are indicated by the return value of pfSphereIsectSeg() which
is either 0, 1, or 2 as appropriate. When the value is 1 or 2, then
the values referenced as d1 and d2 are updated to the distances
along the segment where the intersection(s) exist.
num = pfSphereIsectSeg(...)
if (num == 0)
no intersection
else
if (num == 1)
only intersection: s.pos + d1*s.dir
else
if (num == 2)
first intersection: s.pos + d1*s.dir
second intersection: s.pos + d2*s.dir
note that the intersection routine is smart, so if the segment
starts inside the sphere or ends inside it, you still get the
proper number of intersections.
michael
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:53:21 PDT