Skip to main content

Spatial orientation / normal of a polygon

Short answer

For three non-collinear vertices V1,V2,V3 in CCW order, normal N=(V2−V1)×(V3−V1)=(A,B,C). D=−N·V1. Plane equation Ax+By+Cz+D=0. The outward normal is used for back-face test and shading.

How do you calculate the spatial orientation of a polygon surface (the surface normal / plane coefficients A, B, C)?

The spatial orientation of a polygon surface is given by its plane equation and especially its normal vector N = (A, B, C).

Plane equation: Ax + By + Cz + D = 0

For three non-collinear vertices (x1,y1,z1), (x2,y2,z2), (x3,y3,z3) taken in counter-clockwise order (seen from the outside):

  • A = y1(z2 − z3) + y2(z3 − z1) + y3(z1 − z2)
  • B = z1(x2 − x3) + z2(x3 − x1) + z3(x1 − x2)
  • C = x1(y2 − y3) + x2(y3 − y1) + x3(y1 − y2)
  • D = −x1(y2z3 − y3z2) − x2(y3z1 − y1z3) − x3(y1z2 − y2z1)

Equivalent method: normal N = (V2 − V1) × (V3 − V1) = (A, B, C), and D = −N · V1.

Meaning

  • N = (A, B, C) is perpendicular to the surface. The unit normal is N/|N|.
  • A point (x, y, z) is inside (behind) the surface if Ax + By + Cz + D < 0, and outside (in front) if > 0.
  • Back-face test: if viewing direction V · N > 0, the surface faces away.
  • Used in shading (angle between N and light direction).

Example: A(1,0,0), B(0,1,0), C(0,0,1) gives N = (1,1,1), D = −1, plane x + y + z − 1 = 0.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Graphics chapter 6 questions →