Here, performing a shear uses the concept of a change of basis. See Change of basis for further information.
Consider a horizontal shear with the y=0 invariant plane. To accomplish this we require a matrix H such that
|x| | x + my + nz |
H |y| = | y |
|z| | z |
where
m is the y shear factor
n is the z shear factor
Such a linear transformation matrix is
| 1 m n |
H = | 0 1 0 |
| 0 0 1 |
The steps to perform a shear with the invariant plane through the origin are
-
Find any basis (x, y, z) such that the basis's x and z axes are parallel to the invariant plane and the positive x-axis direction of the basis points in the direction of the shear:
|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 shear as a horizontal shear with the y=0 invariant plane:
| 1 m n | H = | 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⁻¹ H B
| m00 m01 m02 | | x.x y.x z.x | | 1 m n | | 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
k00 = x.x + m*y.x + n*z.x
k01 = x.y + m*y.y + n*z.y
k02 = x.z + m*y.z + n*z.z
m00 = x.x*k00 + y.x*y.x + z.x*z.x
m01 = x.x*k01 + y.x*y.y + z.x*z.y
m02 = x.x*k02 + y.x*y.z + z.x*z.z
m10 = x.y*k00 + y.y*y.x + z.y*z.x
m11 = x.y*k01 + y.y*y.y + z.y*z.y
m12 = x.y*k02 + y.y*y.z + z.y*z.z
m20 = x.z*k00 + y.z*y.x + z.z*z.x
m21 = x.z*k01 + y.z*y.y + z.z*z.y
m22 = x.z*k02 + y.z*y.z + z.z*z.z
The steps to perform a shear with the invariant plane as a general plane are
-
Find any frame (o, x, y, z) such that the origin of the frame coincides with the invariant plane, the frame's x and z axes are parallel to the invariant plane, and the positive x-axis direction of the frame points in the direction of the shear:
|o.x| |x.x| |y.x| |z.x| o = |o.y| x = |x.y| y = |y.y| z = |z.y| |o.z| |x.z| |y.z| |z.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 basis 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 shear as a horizontal shear with the y=0 invariant plane:
| 1 m n 0 | H = | 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⁻¹ H F
| x.x y.x z.x o.x | | 1 m n 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)
k00 = x.x + m*y.x + n*z.x
k01 = x.y + m*y.y + n*z.y
k02 = x.z + m*y.z + n*z.z
k03 = t0 + m*t1 + n*t2
m00 = x.x*k00 + y.x*y.x + z.x*z.x
m01 = x.x*k01 + y.x*y.y + z.x*z.y
m02 = x.x*k02 + y.x*y.z + z.x*z.z
m03 = x.x*k03 + y.x*t1 + z.x*t2 + o.x
m10 = x.y*k00 + y.y*y.x + z.y*z.x
m11 = x.y*k01 + y.y*y.y + z.y*z.y
m12 = x.y*k02 + y.y*y.z + z.y*z.z
m13 = x.y*k03 + y.y*t1 + z.y*t2 + o.y
m20 = x.z*k00 + y.z*y.x + z.z*z.x
m21 = x.z*k01 + y.z*y.y + z.z*z.y
m22 = x.z*k02 + y.z*y.z + z.z*z.z
m23 = x.z*k03 + y.z*t1 + z.z*t2 + o.z