Here is a slight modification of the last query, for dumping the transformation parameters in the order that ST_Affine() expects:
SELECT (bb0*cc01+bb1*cc11+bb2*cc12)AS a, (bb0*cc02+bb1*cc12+bb2*cc22)AS b, (aa0*cc01+aa1*cc11+aa2*cc12)AS d, (aa0*cc02+aa1*cc12+aa2*cc22)AS e, (bb0*cc00+bb1*cc01+bb2*cc02)AS xoff, (aa0*cc00+aa1*cc01+aa2*cc02)AS yoff FROM aa,bb,inv_cc;
a | b | d | e | xoff | yoff
------------------+---------------------+---------------------+-------------------+------------------+------------------
1.00231638907948 | 0.00918961946271679 | -0.0135202854235867 | 0.997400773420259 | 5017.08164289594 | -28138.394850347
Format of transformation parameters
Here is a slight modification of the last query, for dumping the transformation parameters in the order that ST_Affine() expects:
(bb0*cc01+bb1*cc11+bb2*cc12) AS a,
(bb0*cc02+bb1*cc12+bb2*cc22) AS b,
(aa0*cc01+aa1*cc11+aa2*cc12) AS d,
(aa0*cc02+aa1*cc12+aa2*cc22) AS e,
(bb0*cc00+bb1*cc01+bb2*cc02) AS xoff,
(aa0*cc00+aa1*cc01+aa2*cc02) AS yoff
FROM aa,bb,inv_cc;
a | b | d | e | xoff | yoff ------------------+---------------------+---------------------+-------------------+------------------+------------------ 1.00231638907948 | 0.00918961946271679 | -0.0135202854235867 | 0.997400773420259 | 5017.08164289594 | -28138.394850347