문제

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!

도움이 되었습니까?

해결책

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).

다른 팁

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);

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

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? =)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top