There are a couple of problems and solutions where affine matrices are decomposed into their separate transformations. However, they are all for the 2D case and I`m finding it difficult to generalise it to higher dimensions. Specifically, I have to decompose them for the 3D case, to variables that represent the individual degrees of freedom such as rotations, translations, scalings, and shears. I don't understand how to do that. Should there be a general approach for the nD case? Should I write out the formulas?
So I think I could write my problem for 3D like this, where I know all entries of A. With unknowns $v$ the scaling vector, $s$ the information needed for shearing which I don't know how to represent, $p$ the translation vector and $\theta, \psi, \phi$ the rotations: $$ A(\theta, \psi, \phi, v, s, p) = R_z(\phi) R_y(\psi) R_x(\theta) Sc(v) Sh(s) + T(p) $$ Maybe I should formulate this differently?
User7530 shows a nice decomposition here but does not explain (enough for my understanding) why and how it works. Especially why the QR decomposition does the trick here and why $\theta = \arctan\left(\frac{d}{a}\right).$
John does domething similar but with less linear algebra and more algebra.
Michael Albanese shows a nice group theory approach to explain what an affine matrix is made up of, but does not say anything about decomposition. Also I don't really understand this.