Graphics Reference
In-Depth Information
// Compute signed distance of point from plane
float dist = Dot(plane.n, p) - plane.d;
// Classify p based on the signed distance
if (dist > PLANE_THICKNESS_EPSILON)
return POINT_IN_FRONT_OF_PLANE;
if (dist < -PLANE_THICKNESS_EPSILON)
return POINT_BEHIND_PLANE;
return POINT_ON_PLANE;
}
Determining appropriate epsilon values is surprisingly nontrivial. Whereas the
issue is glossed over here, Chapter 11 discusses this issue in detail.
As an example of classification of polygons to a thick plane, consider the four
triangles of Figure 8.10. For triangle ABC , vertex A lies on the plane, and vertices B
and C lie behind the plane. Because there is at least one vertex behind the plane and
no vertices in front of the plane, ABC is classified as lying behind the plane. Triangle
DEF has one vertex, D , in front of the plane and two vertices, E and F , on the plane.
As there is at least one vertex in front of the plane and no vertices behind the plane,
DEF is classified as lying in front of the plane. Note that DEF is considered in front of
the plane even though E lies in the negative halfspace of the plane n
·
( X
P )
=
0,
as E is classified as being on the plane rather than behind it.
The triangle GHI is classified as straddling the dividing plane because there is at
least one vertex in front of the plane and one behind the plane ( G and I , respectively).
Triangle JKL is classified as coplanar with the plane in that all of its vertices lie on
the thickened plane. The following code illustrates how this approach extends to
classifying an arbitrary polygon with respect to a dividing plane.
ε
ε
I
A
G
C
H
P
B
n
P
n
J
L
F
D
E
K
Figure 8.10 Triangle ABC lies behind the plane and triangle DEF lies in front of the plane.
Triangle GHI straddles the plane and triangle JKL lies on the plane.
Search WWH ::




Custom Search