tags:

views:

84

answers:

1

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?

+2  A: 

I'll preface this by saying it is my best guess...

It's possible that TFORMINV may perform the transformation without actually forming the inverse matrix. For example, you can solve a system of linear equations Ax = b in two ways:

x = inv(A)*b;
x = A\b;

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". TFORMINV may do something similar and thus show better overall behavior compared with passing the inverse matrix to TFORMFWD.

If you were so inclined, you could probably try a number of different transformation matrices and test the two approaches (TFORMINV or TFORMFWD and INV) to see how accurate the results are and how fast they are each computed.

gnovice
Thanks, I was looking for an answer along these lines
Jacob
I've tested them for accuracy, and they're the same (I'm not concerned about speed at the moment, just accuracy).
Jacob
@Jacob: If you were to use a transformation matrix that was badly-conditioned (i.e. close to, but not exactly, singular), the two methods may display different results.
gnovice

related questions