Example: Plane Equations
Orientation of a polygon ?
Often in the graphics pipeline, we need to know the orientation
of an object. It would be useful to store the plane equation with the polygons
so that this information doesn't have to be computed each time.
The plane equation takes the form:
P(M) = Ax + By + Cz + D = 0
Using any three points from a polygon, we can solve
for the coefficients. Then we can use the equation to determine whether
a point is on the inside or outside of the plane formed by this polygon:
Ax + By + Cz + D < 0 ==> inside
Ax + By + Cz + D > 0 ==> outside
Normal to the plane
The coefficients A, B, and C can also be used to
determine a vector normal to the plane of the polygon. This vector, called
the surface normal, is given simply by:
N = (A, B, C).
If we specify the vertices of a polygon counterclockwise
when viewing the outer side, in a right-handed coordinate system, the
surface normal N will point from inside to outside. You can verify this
from an alternate definition for N, based on three vertices:
N = (V2 - V1) x (V3 - V1) = (A, B, C)
If we find N in this way, we still need D to complete
the plane equation. The value of D is simply the dot product of the surface
normal with any point in the polygon:
Whichever Q that belong to P : N . OQ = -D
Whichever R, P(R) = ||N|| . dist(P, R)
P(R) = N.OR + D = N.(OQ + QR) + D = N.QR
with Q the projection R on P
|
 |