Hi, Clément-
To your question about inverting the affine, please note that this step does more than just invert the affine:
# get approximate rotation part of affine file AFF, and invert it
cat_matvec \
-ONELINE \
AFF -IP \
> AFF_IP
since both "-I" and "-P" are used:
-P = Do a polar decomposition on the 3x3 matrix part
of the mfile. This would result in an orthogonal
matrix (rotation only, no scaling) Q that is closest,
in the Frobenius distance sense, to the input matrix A.
This is then used to "unrotate" the other matrix, when applied. The idea is to remove the rigid body parts (bulk translation and rotation) from the transformation parts, leaving the shear, scale, and local warps.
--pt