Game Development Reference
In-Depth Information
Figure 7.9 Sphere-plane intersection in a case where they don't intersect.
As with sphere-sphere intersection, the code for sphere-plane intersection is not
that complex, and is outlined in Listing 7.5 .
Listing 7.5 Sphere versus Plane Intersection
Click here to view code image
function SpherePlaneIntersection( BoundingSphere s ,
Plane p )
// Calculate d for the plane with normal
p.normal and
// point on plane s.center
float dSphere = -DotProduct( p . normal , s . center )
// Check if we're within range
return (abs( d - dSphere ) < s . radius )
end
Search WWH ::




Custom Search