11

I know the transformation matrices for rotation, scaling, translation etc. I also know the matrix for shear transformation. Now, I need to have the shear matrix--

[1 Sx 0]
[0 1  0]
[0 0  1]

in the form of a combination of other aforesaid transformations. Tried searching, tried brainstorming, but unable to strike! Thanks!

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Kunal S. Kushwah
  • 883
  • 1
  • 8
  • 19
  • Translation and scaling will have no effect on shearing since they operate on different elements of the matrix. A rotation can be composed of 3 shears, but I've not heard of doing it the other way around. Can you rephrase the question, perhaps? Why do you need this matrix to be composed of other transformations? Also, once you compose the final matrix, you have no way of knowing how it was originally composed, as many different combinations can lead to that result, so what is the circumstance where you need this? – user1118321 Aug 22 '13 at 03:51

4 Answers4

12

The x-shear operation for a shearing angle thetareduces to rotations and scaling as follows:

(a) Rotate by theta/2 counter-clockwise.

(b) Scale with x-scaling factor = sin(theta/2) and y-scaling factor = cos(theta/2).

(c) Rotate by 45 degree clockwise.

(d) Scale with x-scaling factor = sqrt(2)/sin(theta) , and y-scaling factor= sqrt(2).

Mike 'Pomax' Kamermans
  • 49,297
  • 16
  • 112
  • 153
Kunal S. Kushwah
  • 883
  • 1
  • 8
  • 19
6

Yup it can be done, a rotation followed by non uniform scaling and reverse rotation. You can find the details here in third question http://www.cs.cmu.edu/~djames/15-462/Fall03/assts/15-462-Fall03-wrAssign1-answer.pdf. you can try the following openGL code as well. It rotates a rectangle by 45 degree then scales in x-axis. and then rotates in -26 degree i.e. atan(0.5). 0.5 comes from finding the angle between x-axis and one side after scaling in x-direction.

glRotatef(-26.0, 0.0, 0.0, 1.0);

glScalef(2,1,1);

glRotatef(45.0, 0.0, 0.0, 1.0);

glRectf(0, 0, 25.0, 25.0);

4

In 3D Graphics we often use a 4x4 Matrix with 16 useful elements. The Identity 4x4 Matrix is as following:

enter image description here

Between those sixteen elements there are 6 different shearing coefficients:

shear XY
shear XZ
shear YX
shear YZ
shear ZX
shear ZY

In Shear Matrix they are as followings:

enter image description here

Because there are no Rotation coefficients at all in this Matrix, six Shear coefficients along with three Scale coefficients allow you rotate 3D objects about X, Y, and Z axis using magical trigonometry (sin and cos).

Here's an example how to rotate 3D object (CCW) about its Z axis using Shear and Scale elements:

enter image description here

Look at 3 different Rotation patterns using Shear and Scale elements:

enter image description here

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
3

Shears are an elementary matrix operation, so while you can express them as "a combination of other matrix operations", doing so is really weird. Shears take the two forms:

| 1 V |    | 1 0 |
| 0 1 | ,  | V 1 |

Whereas a rotation matrix is much more involved; the idea of expressing a shear using rotations suggests you haven't actually written these things out yet to see what you need, so let's look at this. A rotation matrix is of the form:

| cos -sin |
| sin  cos |

Which can be composed as a sequence of three particular shear matrices, R = Sx x Sy x Sx:

| cos(a) -sin(a) |   |     1      0 |   | 1  sin(a) |   |     1      0 |
|                | = |              | x |           | x |              |
| sin(a)  cos(a) |   | -tan(a/2)  1 |   | 0    1    |   | -tan(a/2)  1 |

Now, we can do some trivial matrix manipulation to get Sy. First left-multiply:

      R = Sx x Sy x Sx
Sx⁻¹ x R = Sx⁻¹ x Sy x Sx
Sx⁻¹ x R = I x Sy x Sx
Sx⁻¹ x R = Sy x Sx

And then right-multiply:

Sx⁻¹ x R x Sx⁻¹ = Sy x Sx x Sx⁻¹
Sx⁻¹ x R x Sx⁻¹ = Sy x I
Sx⁻¹ x R x Sx⁻¹ = Sy

As a trivial rewrite, one shear is now two shears and a rotation.

But the much more important question is: why do you need to express the shear matrix as something else? It's already an elementary matrix form, what bizare computing environment are you in, or what crazy thing are you trying to do, that requires you to express an elementary transform as a way more complex, way slower thing to compute? =)

Mike 'Pomax' Kamermans
  • 49,297
  • 16
  • 112
  • 153
  • Out of topic, your opinion should supplement the answer (which exists in this case) to the ops' question. Second guessing should be done in comments IMHO – arkan May 13 '21 at 07:28