Allegro.cc Forums » Programming Questions » Is composing horz + vert shear the same thing as shearing both?

 Bruce Pascoe Member #15,931 April 2015 That topic title was probably confusing, so here's a better explanation: Allegro has these functions for doing shear transformation:```al_horizontal_shear_transform() al_vertical_shear_transform() ``` If I call both of these in sequence, is that the same thing as shearing both X and Y simultaneously? Think of CSS transformations, it has skewX/skewY() and then just skew() to do both at the same time.I ask this because, in general, matrix multiplication is not commutative. For example translate + rotate is not the same thing as rotate + translate, and I wonder if the same caveat applies here.
 SiegeLord Member #7,827 October 2006 No, you do indeed get different effects depending on which way you skew first. To skew on both axes simulateously, you need a matrix that looks like this:```1 x 0 0 y 1 0 0 0 0 1 0 0 0 0 1 ``` Which Allegro doesn't have a simple function to create. I'd do this:```ALLEGRO_TRANSFORM t; al_identity_transform(&t); t.m[1][0] = x; t.m[0][1] = y; al_compose_transform(&your_transform, &t); ``` "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]