4x4 Matrix Transformation of the Implicit Form of the Plane
Kenneth E. Hoff III
7/13/98
Given a plane as a 4-vector [ A B C D ] whose components are the coefficients of the implicit form of the plane Ax+By+Cz+D where (A,B,C) is the normal to the plane (possibly not normalized) and D is the negative distance from the origin to the plane along the normal (in units of the normal's length if not normalized), and a 4x4 transformation matrix M, we wish to transform the plane.
The simplest method would be to convert the implicit form of the plane to the point-normal form. We already have the normal as (A,B,C) and we can obtain a point on the plane as follows:
PtOnPlane = -D*(A,B,C)
This is simple since -D is the negative distance from the origin to the plane along the normal (in units of the normal, if not normalized).
So now we have the point-normal form as 1 point on the plane and 1 vector that is the plane's normal. We can perform two transformations as follows:
NewNormal N' = M * Normal NewPtOnPlane P' = M * PtOnPlane
Through substitution and expansion we get:
[ N'x ] = M * [ A ] [ N'y ] [ B ] [ N'z ] [ C ] [ 0 ] [ 0 ] [ P'x ] = M * [ -AD ] [ P'y ] [ -BD ] [ P'z ] [ -CD ] [ 1 ] [ 1 ]
We can get the implicit form [ A' B' C' D' ] for the xformed plane as follows:
We should be able to remove the conversion step by expanding the terms:
[ A' ] [ M00*A + M01*B + M02*C ]
[ B' ] = [ M10*A + M11*B + M12*C ]
[ C' ] [ M20*A + M21*B + M22*C ]
[ D' ] = -( (M00*-AD + M01*-BD + M02*-CD + M03) * (M00*A + M01*B + M02*C) +
(M10*-AD + M11*-BD + M12*-CD + M13) * (M10*A + M11*B + M12*C) +
(M20*-AD + M21*-BD + M22*-CD + M23) * (M20*A + M21*B + M22*C) )
= -( (-D * (M00*A + M01*B + M02*C) + M03) * A' +
(-D * (M10*A + M11*B + M12*C) + M13) * B' +
(-D * (M20*A + M21*B + M22*C) + M23) * C' )
= -( (-DA' + M03) * A' +
(-DB' + M13) * B' +
(-DC' + M23) * C' )
This gives an efficient and compact form for the planar xform without renormalization of the normal. We could then normalize as follows:
L = sqrt(A'2+B'2+C'2) [ A B C D ] = [ A/L B/L C/L D/L ]
We could incorporate the normalization into the calculation more efficiently by reordering the operations of D' to compute (A'2+B'2+C'2):
D' = -(-DA' + M03) * A' + (-DB' + M13) * B' + (-DC' + M23) * C' = -(-DA'2 + A'M03 + -DB'2 + B'M13 + -DC'2 + C'M23) = -(-D*(A'2 + B'2 + C'2) + (A'M03 + B'M13 + C'M23)) = D*(A'2 + B'2 + C'2) - (A'M03 + B'M13 + C'M23)
So now we can compute an intermediate value L2 (length squared) before computing D' and normalization:
L2 = A'2 + B'2 + C'2 D' = D*L2 - (A'M03 + B'M13 + C'M23) L = sqrt(L2) [ A B C D ] = [ A'/L B'/L C'/L D'/L ]
<OR MORE EFFICIENTLY>
L2 = A'2 + B'2 + C'2 L = sqrt(L2) [ A B C ] = [ A'/L B'/L C'/L ] D' = D*L2 - (A*M03 + B*M13 + C*M23)
Note that this assumes that the 4x4 matrix does not include a projection, a shear, or a nonuniform scaling. What does it mean to project an infinite plane?