Point-Normal Form of a Line and a Plane

The purpose of this paper is to show how to describe a line and a plane in the Point-Normal form which can be used to simplify intersection calculations for use in clipping and raytracing.

Kenny Hoff (Oct. 2, 1995)
based on F.S. Hill's Computer Graphics


Point-Normal form for a line

Given two endpoints (lines do not have endpoints, but this is a typical application) A and B, it is often useful to have a form of the line based on a perpendicular vector called the normal. This normal gives clues as to the "facing" direction of the line or the inside-outside halfspaces created by the spaces on each side of the line. The normal is said to be the "front facing" direction of the line or the direction of the "inside" space. However, the normal can be facing either direction (there are two direction perpendicular to a line) so the "inside direction" or "front-facing" normal is merely a convention that must be determined by the modeler. The method that follows will be a consistent representation for all lines which will represent the normal as a 90 degree rotation of the line in a counter-clockwise direction.

The Point-Normal form of a line is simply n.p=D (the dot product of the normal to the line and a point on the line equals the distance to the line along the normal vector). Given points A and B for a line segment we can use either point for the point p, but to be consistent we will always use A. The normal is simply the direction vector of the line to point B (B-A) rotated 90 degrees in a counter-clockwise direction. The direction vector of AB is (Bx-Ax, By-Ay). From this, it can easily be shown that the slope of the line is dy/dx ((By-Ay)/(Bx-Ax)), and the slope of the line perpendicular to this is merely the inverse slope (-dx/dy). To the normal n to this line can be derived as follows:

	direction vector = B-A = (run, rise)
	run = dx = Bx-Ax
	rise = dy = By-Ay
	slope = rise/run = dy/dx
	inverse slope = -run/rise = -dx/dy = ( -(Bx-Ax) / (By-Ay) )

	n = normal vector = (rise, -run) = (dy, -dx) = ( (By-Ay), -(Bx-Ax) )

However, this gives us the normal vector rotated 90 degrees in a clockwise direction. Since it does not matter which component of the normal we negate in order to obtain the inverse slope, we will write the normal n as follows in order to get the 90 degree counter-clockwise version:

	n = normal vector = (-rise, run) = (-dy, dx) = ( -(By-Ay), (Bx-Ax) )

Now to find D, we can use the normal n, the point A, and the Point-Normal equation (n.p=D):

	D = n.A = (nx * Ax) + (ny * Ay)

And that's all there is to it. We now have the Point-Normal form that defines the line using the normal. The p in n.p=D refers to all points on the line; the normal n and the distance D are constants in the equation. For clarity, if we expand out the Point-Normal form of the line we will obtain the more common line equation:

	n.p=D
	nx*px + ny*py = D
	A*x + B*y = D
	A*x + B*y + C = 0


Point-Normal form for a plane

Believe it or not, the Point-Normal form for a plane is exactly the same as the line version n.p=D; however, this time the vectors n and p are three-dimensional and the normal to the plane is derived differently.

So, like above, we must first derive the normal n to the plane. Given three consecutive vertices A, B, and C defining a 3D polygon, we can obtain the normal by calculating the cross-product of the vectors B to A and B to C:

	u = vector from B to A = (A-B)
	v = vector from B to C = (C-B)
	Normal n = u X v
	         = (uy*vz - uz*vy)i + (uz*vx - ux*vz)j + (ux*vy - uy*vx)k

n = ( (uy*vz - uz*vy), (uz*vx - ux*vz), (ux*vy - uy*vx) )

i, j, and k are the standard 3D unit vectors. So now we should ask which way is this normal facing? The cross-product uses the right-hand rule to determine the direction of the normal. If we wrap our right-hand fingers in the direction of A to B to C around the face of the polygon we will define the direction of our normal as the direction our thumbs our pointing. So if the consecutive vertices are defined in a counter-clockwise fashion around the polygon with respect to the viewing direction, the normal will be facing the viewer. Make sense?

The distance D along this normal n to the plane can be found, just as with the Point-Slope form of the line, by solving for the equation n.p=D using the first vertex A as point p:

	D = n.A = (nx * Ax) + (ny * Ay) + (nz * Az)

Just as above, if we expand the Point-Normal form of the plane we will obtain the familiar plane equation:

	n.p=D
	nx*px + ny*py + nz*pz = D
	A*x + B*y + C*z = D
	A*x + B*y + C*z - D = 0          (here D being a constant)