6

Is there a way to calculate the skew transformation matrix along one coordinate axis, given the skew angle, as follows

enter image description here

rraallvv
  • 2,875
  • 6
  • 30
  • 67

1 Answers1

14

This should work for the most part for skewing an object with a transformation matrix, in particular using glMultMatrix(matrix)

enter image description here

matrix1[] = {
1,  0,  0,  0,
tan(a), 1,  0,  0,
0,  0,  1,  0,
0,  0,  0,  1
};

matrix2[] = {
    1,  0,  0,  0,
    0,  1,  0,  0,
    tan(a), 0,  1,  0,
    0,  0,  0,  1
};

matrix3[] = {
    1,  tan(a), 0,  0,
    0,  1,  0,  0,
    0,  0,  1,  0,
    0,  0,  0,  1
};

matrix4[] = {
    1,  0,  0,  0,
    0,  1,  0,  0,
    0,  tan(a), 1,  0,
    0,  0,  0,  1
};

matrix5[] = {
    1,  0,  tan(a), 0,
    0,  1,  0,  0,
    0,  0,  1,  0,
    0,  0,  0,  1
};

matrix6[] = {
    1,  0,  0,  0,
    0,  1,  tan(a), 0,
    0,  0,  1,  0,
    0,  0,  0,  1
};
rraallvv
  • 2,875
  • 6
  • 30
  • 67
  • 1
    Specifics: 1) skew along x, relative to the y axis, 2) skew along x, relative to the z axis, 3) skew along y, relative to the x axis, 4) skew along y, relative to the z axis, 5) skew along z, relative to the x axis, 6) skew along z relative to the y axis. You can see this is the placement of the `tan(a)` in the matrix too, eg 1) **when you multiply a vector with the matrix, the y component of the result is affected by the `tan(a)` -- affected by the amount of the x component of the vector. Another way to think about it is as x gets bigger, there is more skew in the y result.** – Kiki Jewell Sep 25 '17 at 16:12