Suppose I have an arbitrary transformation matrix A such as,
A =
0.9966 0.0007 -6.5625
0.0027 0.9938 1.0598
0 0 1.0000
And a set of points such that their x and y coordinates are represented by X and Y respectively.
And suppose,
[Xf Yf] = tformfwd(maketform('projective',A),X,Y);
Now,
[Xff Yff] = tformfwd(maketform('projective',inv(A)),Xf,Yf);
[Xfi Yfi] = tforminv(maketform('projective',A),Xf,Yf);
[Xff Yff] and [Xfi Yfi] seem to be exactly the same (and they should).
Is tforminv just there for convenience or am I missing something here?
I’ll preface this by saying it is my best guess…
It’s possible that
tforminvmay perform the transformation without actually forming the inverse matrix. For example, you can solve a system of linear equationsAx = bin two ways:According to the documentation for
inv, the second option (using the matrix division operator) can perform better “from both an execution time and numerical accuracy standpoint” since it “produces the solution using Gaussian elimination, without forming the inverse”.tforminvmay do something similar and thus show better overall behavior compared with passing the inverse matrix totformfwd.If you were so inclined, you could probably try a number of different transformation matrices and test the two approaches (
tforminvortformfwdandinv) to see how accurate the results are and how fast they are each computed.