Here, reflecting in a plane uses the concept of a change of basis. See Change of basis for further information.
The steps to perform a reflection in a plane through the origin are
-
Find any basis (x, y, z) such that the normal of the plane is codirectional with the positive x-axis direction of the basis:
|x.x| |y.x| |z.x| x = |x.y| y = |y.y| z = |z.y| |x.z| |y.z| |z.z|
-
Perform a change of basis from the implied reference basis to the new basis:
| x.x x.y x.z | B = | y.x y.y y.z | | z.x z.y z.z |
-
Perform the reflection as a reflection in the x=0 plane:
| -1 0 0 | R = | 0 1 0 | | 0 0 1 |
-
Perform a change of basis back to the implied reference basis:
| x.x y.x z.x | B⁻¹ = | x.y y.y z.y | | x.z y.z z.z |
Combine these steps into one matrix M:
M = B⁻¹ R B
| m00 m01 m02 | | x.x y.x z.x | | -1 0 0 | | x.x x.y x.z |
| m10 m11 m12 | = | x.y y.y z.y | | 0 1 0 | | y.x y.y y.z |
| m20 m21 m22 | | x.z y.z z.z | | 0 0 1 | | z.x z.y z.z |
where
m00 = -x.x*x.x + y.x*y.x + z.x*z.x
m01 = -x.x*x.y + y.x*y.y + z.x*z.y
m02 = -x.x*x.z + y.x*y.z + z.x*z.z
m10 = -x.y*x.x + y.y*y.x + z.y*z.x
m11 = -x.y*x.y + y.y*y.y + z.y*z.y
m12 = -x.y*x.z + y.y*y.z + z.y*z.z
m20 = -x.z*x.x + y.z*y.x + z.z*z.x
m21 = -x.z*x.y + y.z*y.y + z.z*z.y
m22 = -x.z*x.z + y.z*y.z + z.z*z.z
The steps to perform a reflection in a general plane are
-
Find any frame (x, y, z, o) such that the origin of the frame coincides with the plane and the frame's positive x-axis direction is codirectional with the normal of the plane:
|x.x| |y.x| |z.x| |o.x| x = |x.y| y = |y.y| z = |z.y| o = |o.y| |x.z| |y.z| |z.z| |o.z| | 1 | | 1 | | 1 | | 1 |
-
Perform a change of frame from the implied reference frame to the new frame:
(Here we translate the new frame's origin to the implied reference frame's origin and then change to the new frame's basis.)
| x.x x.y x.z 0 | | 1 0 0 -o.x | F = | y.x y.y y.z 0 | | 0 1 0 -o.y | | z.x z.y z.z 0 | | 0 0 1 -o.z | | 0 0 0 1 | | 0 0 0 1 | | x.x x.y x.z -(x.x*o.x + x.y*o.y + x.z*o.z) | = | y.x y.y y.z -(y.x*o.x + y.y*o.y + y.z*o.z) | | z.x z.y z.z -(z.x*o.x + z.y*o.y + z.z*o.z) | | 0 0 0 1 |
-
Perform the reflection as a reflection in the x=0 plane:
| -1 0 0 0 | R = | 0 1 0 0 | | 0 0 1 0 | | 0 0 0 1 |
-
Perform a change of frame back to the implied reference frame:
| 1 0 0 o.x | | x.x y.x z.x 0 | F⁻¹ = | 0 1 0 o.y | | x.y y.y z.y 0 | | 0 0 1 o.z | | x.z y.z z.z 0 | | 0 0 0 1 | | 0 0 0 1 | | x.x y.x z.x o.x | = | x.y y.y z.y o.y | | x.z y.z z.z o.z | | 0 0 0 1 |
Combine these steps into one matrix M:
M = F⁻¹ R F
| x.x y.x z.x o.x | | -1 0 0 0 | | x.x x.y x.z t0 |
= | x.y y.y z.y o.y | | 0 1 0 0 | | y.x y.y y.z t1 |
| x.z y.z z.z o.z | | 0 0 1 0 | | z.x z.y z.z t2 |
| 0 0 0 1 | | 0 0 0 1 | | 0 0 0 1 |
| m00 m01 m02 m03 |
= | m10 m11 m12 m13 |
| m20 m21 m22 m23 |
| 0 0 0 1 |
where
t0 = -(x.x*o.x + x.y*o.y + x.z*o.z)
t1 = -(y.x*o.x + y.y*o.y + y.z*o.z)
t2 = -(z.x*o.x + z.y*o.y + z.z*o.z)
m00 = -x.x*x.x + y.x*y.x + z.x*z.x
m01 = -x.x*x.y + y.x*y.y + z.x*z.y
m02 = -x.x*x.z + y.x*y.z + z.x*z.z
m03 = -x.x*t0 + y.x*t1 + z.x*t2 + o.x
m10 = -x.y*x.x + y.y*y.x + z.y*z.x
m11 = -x.y*x.y + y.y*y.y + z.y*z.y
m12 = -x.y*x.z + y.y*y.z + z.y*z.z
m13 = -x.y*t0 + y.y*t1 + z.y*t2 + o.y
m20 = -x.z*x.x + y.z*y.x + z.z*z.x
m21 = -x.z*x.y + y.z*y.y + z.z*z.y
m22 = -x.z*x.z + y.z*y.z + z.z*z.z
m23 = -x.z*t0 + y.z*t1 + z.z*t2 + o.z