Calculating a transformation matrix for a given pair of matrices

17 Views Asked by At

Simple deduction tells me that given square matrices $A*B=C$, we can calculate $B=C*A^{-1}$, but writing the code using OpenCV's cv::Mats things don't calculate correctly. Basically I have:

$\begin{pmatrix}a & b & c & d\\\ e & f & g & h\\\ i & j & k & l\\\ 0 &0 &0 &1\end{pmatrix} * B = \begin{pmatrix}-e & -f & g & -h\\\ -a & b & c & d\\\ i & j & k & l\\\ 0 &0 &0 &1\end{pmatrix}$

Evaluating $B=C*A^{-1}$ for sample data gives me $\begin{pmatrix}0 & -1 & 0 & 0\\\ 1 & 0 & 0 &0\\\ 0 & 0 & 1 & 0\\\ 0 &0 &0 &1\end{pmatrix}$, but using that matrix in $A*B=C$ doesn't get me back where I started.

What is $B$ and what am I doing wrong? I am basically wanting to change the coordinate system from $X$ forward and $Y$ left to $X$ right and $Y$ forward, basically $90^{\circ}$ rotation in the $Z$ plane (assuming I've got my terminology right!).