In the plane R 2 = R × R {\displaystyle \mathbb {R} ^{2}=\mathbb {R} \times \mathbb {R} } , a horizontal shear (or shear parallel to the x-axis) is a function that takes a generic point with coordinates ( x , y ) {\displaystyle (x,y)} to the point ( x + m y , y ) {\displaystyle (x+my,y)} ; where m is a fixed parameter, called the shear factor.
The effect of this mapping is to displace every point horizontally by an amount proportionally to its y-coordinate. Any point above the x-axis is displaced to the right (increasing x) if m > 0, and to the left if m < 0. Points below the x-axis move in the opposite direction, while points on the axis stay fixed.
Straight lines parallel to the x-axis remain where they are, while all other lines are turned (by various angles) about the point where they cross the x-axis. Vertical lines, in particular, become oblique lines with slope 1 m . {\displaystyle {\tfrac {1}{m}}.} Therefore, the shear factor m is the cotangent of the shear angle φ {\displaystyle \varphi } between the former verticals and the x-axis. In the example on the right the square is tilted by 30°, so the shear angle is 60°.
If the coordinates of a point are written as a column vector (a 2×1 matrix), the shear mapping can be written as multiplication by a 2×2 matrix:
A vertical shear (or shear parallel to the y-axis) of lines is similar, except that the roles of x and y are swapped. It corresponds to multiplying the coordinate vector by the transposed matrix:
The vertical shear displaces points to the right of the y-axis up or down, depending on the sign of m. It leaves vertical lines invariant, but tilts all other lines about the point where they meet the y-axis. Horizontal lines, in particular, get tilted by the shear angle φ {\displaystyle \varphi } to become lines with slope m.
Two or more shear transformations can be combined.
If two shear matrices are ( 1 λ 0 1 ) {\textstyle {\begin{pmatrix}1&\lambda \\0&1\end{pmatrix}}} and ( 1 0 μ 1 ) {\textstyle {\begin{pmatrix}1&0\\\mu &1\end{pmatrix}}}
then their composition matrix is ( 1 λ 0 1 ) ( 1 0 μ 1 ) = ( 1 + λ μ λ μ 1 ) , {\displaystyle {\begin{pmatrix}1&\lambda \\0&1\end{pmatrix}}{\begin{pmatrix}1&0\\\mu &1\end{pmatrix}}={\begin{pmatrix}1+\lambda \mu &\lambda \\\mu &1\end{pmatrix}},} which also has determinant 1, so that area is preserved.
In particular, if λ = μ {\displaystyle \lambda =\mu } , we have
( 1 + λ 2 λ λ 1 ) , {\displaystyle {\begin{pmatrix}1+\lambda ^{2}&\lambda \\\lambda &1\end{pmatrix}},}
which is a positive definite matrix.
A typical shear matrix is of the form S = ( 1 0 0 λ 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 ) . {\displaystyle S={\begin{pmatrix}1&0&0&\lambda &0\\0&1&0&0&0\\0&0&1&0&0\\0&0&0&1&0\\0&0&0&0&1\end{pmatrix}}.}
This matrix shears parallel to the x axis in the direction of the fourth dimension of the underlying vector space.
A shear parallel to the x axis results in x ′ = x + λ y {\displaystyle x'=x+\lambda y} and y ′ = y {\displaystyle y'=y} . In matrix form: ( x ′ y ′ ) = ( 1 λ 0 1 ) ( x y ) . {\displaystyle {\begin{pmatrix}x'\\y'\end{pmatrix}}={\begin{pmatrix}1&\lambda \\0&1\end{pmatrix}}{\begin{pmatrix}x\\y\end{pmatrix}}.}
Similarly, a shear parallel to the y axis has x ′ = x {\displaystyle x'=x} and y ′ = y + λ x {\displaystyle y'=y+\lambda x} . In matrix form: ( x ′ y ′ ) = ( 1 0 λ 1 ) ( x y ) . {\displaystyle {\begin{pmatrix}x'\\y'\end{pmatrix}}={\begin{pmatrix}1&0\\\lambda &1\end{pmatrix}}{\begin{pmatrix}x\\y\end{pmatrix}}.}
In 3D space this matrix shear the YZ plane into the diagonal plane passing through these 3 points: ( 0 , 0 , 0 ) {\displaystyle (0,0,0)} ( λ , 1 , 0 ) {\displaystyle (\lambda ,1,0)} ( μ , 0 , 1 ) {\displaystyle (\mu ,0,1)} S = ( 1 λ μ 0 1 0 0 0 1 ) . {\displaystyle S={\begin{pmatrix}1&\lambda &\mu \\0&1&0\\0&0&1\end{pmatrix}}.}
The determinant will always be 1, as no matter where the shear element is placed, it will be a member of a skew-diagonal that also contains zero elements (as all skew-diagonals have length at least two) hence its product will remain zero and will not contribute to the determinant. Thus every shear matrix has an inverse, and the inverse is simply a shear matrix with the shear element negated, representing a shear transformation in the opposite direction. In fact, this is part of an easily derived more general result: if S is a shear matrix with shear element λ, then Sn is a shear matrix whose shear element is simply nλ. Hence, raising a shear matrix to a power n multiplies its shear factor by n.
If S is an n × n shear matrix, then:
For a vector space V and subspace W, a shear fixing W translates all vectors in a direction parallel to W.
To be more precise, if V is the direct sum of W and W′, and we write vectors as
correspondingly, the typical shear L fixing W is
where M is a linear mapping from W′ into W. Therefore in block matrix terms L can be represented as
The following applications of shear mapping were noted by William Kingdon Clifford:
The area-preserving property of a shear mapping can be used for results involving area. For instance, the Pythagorean theorem has been illustrated with shear mapping3 as well as the related geometric mean theorem.
Shear matrices are often used in computer graphics.456
An algorithm due to Alan W. Paeth uses a sequence of three shear mappings (horizontal, vertical, then horizontal again) to rotate a digital image by an arbitrary angle. The algorithm is very simple to implement, and very efficient, since each step processes only one column or one row of pixels at a time.7
In typography, normal text transformed by a shear mapping results in oblique type.
In pre-Einsteinian Galilean relativity, transformations between frames of reference are shear mappings called Galilean transformations. These are also sometimes seen when describing moving reference frames relative to a "preferred" frame, sometimes referred to as absolute time and space.
Weisstein, Eric W. "Shear". MathWorld − A Wolfram Web Resource. Definition according to Weisstein. http://mathworld.wolfram.com/Shear.html ↩
Clifford, William Kingdon (1885). Common Sense and the Exact Sciences. p. 113. /wiki/William_Kingdon_Clifford ↩
Hohenwarter, M. "Pythagorean theorem by shear mapping". Made using GeoGebra. Drag the sliders to observe the shears. http://tube.geogebra.org/m/125392 ↩
Foley et al. (1991, pp. 207–208, 216–217) - Foley, James D.; van Dam, Andries; Feiner, Steven K.; Hughes, John F. (1991), Computer Graphics: Principles and Practice (2nd ed.), Reading: Addison-Wesley, ISBN 0-201-12110-7 https://archive.org/details/computergraphics00fole ↩
Schneider, Philip J.; Eberly, David H. (2002). "Geometric Tools for Computer Graphics". pp. 154–157. https://books.google.com/books?id=3Q7HGBx1uLIC ↩
Desai, Apueva A. "Computer Graphics". pp. 162–164. https://books.google.com/books?id=WQiIj8ZS0IoC ↩
Paeth, A.W. (1986). "A Fast Algorithm for General Raster Rotation" (PDF). Vision Interface (VI1986). pp. 077–081. https://www.cipprs.org/archive/vi/VI1986/pp077-081-Paeth-1986.pdf ↩