## Plane equations and the Normal to a polygon

Remember a straight line is of form: y= mx + b or ax + by + c = 0 (where x, y is a point on the line) similarly a plane equation is: ax + by + cz + d = 0 ( x, y, z is any point on the plane)

Can find a, b, c, d by using any 4 non-collinear points. a, b, and c are the x, y, and z components of the plane normal. d is the distance of the plane from the origin (if all components are normalized). Look at using three polygon vertices to determine N (assume a planar polygon).

Now we define the "inside" of the polygon as facing object interior , "outside" is other side.

Now specify polygon vertices in counterclockwise order when viewed from outside (as in the above figure).

Next define 2 vectors in plane,V1 , V2 -> V1 = P2 - P 1 V2 = P3 - P1

then N = V1 x V2 é i j k ù = ê x1 y1 z1ú ë x2 y2 z2û

where x1 = (P2x - P1x) x2 = (P3x - P1z) y1 = (P2y - P1y) y2 = (P3y - P1y) z1 = (P2z - P1z) z2 = (P3z - P1z) Above yields N = ai +bj +ck

Then to find D in plane equation substitute any other point in the plane into the plane equation. Alternative method using just 3 non-collinear points on the polygon: Solve the linear system Axi + Byi + Czi + D = 0 for i = 1, 2, 3 this gives: 1 y1 z1 x1 1 z1 x1 y1 1 x1 y1 z1 A = 1 y2 z2 B = x2 1 z2 C = x2 y2 1 D = x2 y2 z2 1 y3 z3 x3 1 z3 x3 y3 1 x3 y3 z3

Look at example using a unit cube: do V1 × V2 Compute plane equation for "front" face P1 = (-1, -1, 1), P2 = (1, -1, 1) P3 = (1, 1, 1), P4 = (-1, 1, 1)

1. Compute Normal -compute vectors V1 = P2 - P1 V2 = P3 - P1

x1 = P2x - P1x = 1 - (-1) = 2 V1 y1 = P2y - P1y = -1 -(-1) = 0 z1 = P2z - P1z = 1 - 1 = 0

x2 = P3x - P1x = 1 -(-1) = 2 V2 y2 = P3y - P1y = 1 -(-1) = 2 z2 = P3z - P1z = 1 - 1 = 0

So N =|i j k| |2 0 0| --> a = 0 b = 0 c = 4 --> N = 4k |2 2 0|

So N parallel to the xy plane and facing in the +z direction.

Now use P4 to find d 0 × (-1) + 0 × 1 + 4 × 1 + d = 0 d = -4

So plane equation : 4z - 4 = 0 ® z = 1 Note: if z > 1 then e.g. z = 2 Plane equation gives: 4 × 2 - 4 = 8 - 4 > 0 in general any point outside of Plane has Plane equation ax + by + cz + d > 0 similarly for z = 0 ® -4 <0

so any point inside plan has plane equation <0

Plane equations and the Normal to a polygon

Remember a straight line is of form: y= mx + b or ax + by + c = 0 (where x, y is a point on the line) similarly a plane equation is: ax + by + cz + d = 0 ( x, y, z is any point on the plane)

Can find a, b, c, d by using any 4 non-collinear points. a, b, and c are the x, y, and z components of the plane normal. d is the distance of the plane from the origin (if all components are normalized). Look at using three polygon vertices to determine N (assume a planar polygon).

Now we define the "inside" of the polygon as facing object interior , "outside" is other side.

Now specify polygon vertices in counterclockwise order when viewed from outside (as in the above figure).

Next define 2 vectors in plane,V1 , V2 -> V1 = P2 - P 1 V2 = P3 - P1

then N = V1 x V2 é i j k ù = ê x1 y1 z1ú ë x2 y2 z2û

where x1 = (P2x - P1x) x2 = (P3x - P1z) y1 = (P2y - P1y) y2 = (P3y - P1y) z1 = (P2z - P1z) z2 = (P3z - P1z) Above yields N = ai +bj +ck

Then to find D in plane equation substitute any other point in the plane into the plane equation. Alternative method using just 3 non-collinear points on the polygon: Solve the linear system Axi + Byi + Czi + D = 0 for i = 1, 2, 3 this gives: 1 y1 z1 x1 1 z1 x1 y1 1 x1 y1 z1 A = 1 y2 z2 B = x2 1 z2 C = x2 y2 1 D = x2 y2 z2 1 y3 z3 x3 1 z3 x3 y3 1 x3 y3 z3

Look at example using a unit cube: do V1 × V2 Compute plane equation for "front" face P1 = (-1, -1, 1), P2 = (1, -1, 1) P3 = (1, 1, 1), P4 = (-1, 1, 1)

1. Compute Normal -compute vectors V1 = P2 - P1 V2 = P3 - P1

x1 = P2x - P1x = 1 - (-1) = 2 V1 y1 = P2y - P1y = -1 -(-1) = 0 z1 = P2z - P1z = 1 - 1 = 0

x2 = P3x - P1x = 1 -(-1) = 2 V2 y2 = P3y - P1y = 1 -(-1) = 2 z2 = P3z - P1z = 1 - 1 = 0

So N =|i j k| |2 0 0| --> a = 0 b = 0 c = 4 --> N = 4k |2 2 0|

So N parallel to the xy plane and facing in the +z direction.

Now use P4 to find d 0 × (-1) + 0 × 1 + 4 × 1 + d = 0 d = -4

So plane equation : 4z - 4 = 0 ® z = 1 Note: if z > 1 then e.g. z = 2 Plane equation gives: 4 × 2 - 4 = 8 - 4 > 0 in general any point outside of Plane has Plane equation ax + by + cz + d > 0 similarly for z = 0 ® -4 <0

so any point inside plan has plane equation <0

Last changed April 01, 1998, G. Scott Owen, owen@siggraph.org