To represent 2D affine transformations I'm using translation, rotation and scale. When I transform a vector I compose the TRS matrix, that is I scale then rotate and finally translate the vector.
That is, given $T, R, S$
$$ T = \begin{bmatrix} t_1 \\ t_2 \end{bmatrix} \\ R = \alpha \\ S = \begin{bmatrix} s_1 \\ s_2 \end{bmatrix} $$ where $s_1 \neq 0$ and $s_2 \neq 0$, I compose the matrix $$ M(T,R,S) = \begin{bmatrix} s_1 \cos \alpha & -s_2 \sin \alpha & t_1 \\ s_1 \sin \alpha & s_2 \cos \alpha & t_2 \\ 0 & 0 & 1 \end{bmatrix} $$ and finally use matrix multiplication to transform the vector.
The problem I'm having is when decomposing several $T, R, S$ transformations. With the case the scale is uniform ($s_1 = s_2$) I can decompose two transformations as
$$ M(T,R,S) = M(T',R',S') \cdot M(T'',R'',S'') \\ T = \begin{bmatrix} s'(t''_1\cos \alpha'- t''_2\sin \alpha') + t'_1 \\ s'(t''_1\sin \alpha'+ t''_2\cos \alpha') + t'_2 \end{bmatrix} \\ R = \alpha' + \alpha'' \\ S = \begin{bmatrix} s's'' \\ s's'' \end{bmatrix} $$ however this only works when scale is uniform.
Is it possible to decompose the above $M(T,R,S)$ matrix to $T,R,S$ form when scale is non-uniform?
When I try it I only end up trying to simplify $a \cos \alpha \cos \beta - b \sin \alpha \sin \beta, b \neq a$ to the form $a' \cos \alpha'$ with no success.
Seems it's possible that scaling, rotating and repeating can add shear so José was right, with non-uniform scale it's not possible.