non uniform scale and then rotation creates squashed sprite.

I am drawing a sprite and when it’s a square and I rotate it, there’s no problem. When I do a non uniform scale such as stretch the height 2x the width then rotate. The sprite will seem to get squished when it is rotated.

I am using the vectormath library; this is rotation code with all the intermediate functions also documented


static inline void vmathM4MakeRotationZ( VmathMatrix4 *result, float radians )
{
    float s, c;
    s = sinf( radians );
    c = cosf( radians );
    vmathV4MakeFromElems( &result->col0, c, s, 0.0f, 0.0f );
    vmathV4MakeFromElems( &result->col1, -s, c, 0.0f, 0.0f );
    vmathV4MakeZAxis( &result->col2 );
    vmathV4MakeWAxis( &result->col3 );
}

static inline void vmathV4MakeFromElems(VmathVector4 *result, float _x,
                                        float _y, float _z, float _w) {
    result->x = _x;
    result->y = _y;
    result->z = _z;
    result->w = _w;
}

static inline void vmathV4MakeZAxis(VmathVector4 *result) {
    vmathV4MakeFromElems(result, 0.0f, 0.0f, 1.0f, 0.0f);
}

Why does a non uniform scale cause such an issue and how can I solve it?

If you’re trying to scale the sprite, the matrices should be multiplied with the rotation on the left and the scale on the right.

changing the multiplication order for my scale and rotation it now rotates properly but if I translate after rotating it seems to offset the origin of the quad.