We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › About applyMatrix()
Page Index Toggle Pages: 1
About applyMatrix() (Read 667 times)
About applyMatrix()
Jan 11th, 2008, 1:45pm
 
There are already functions to translate(), rotate(), and scale(), but I was looking for a way to mirror coordinates (in 2D), e.g. (x, y) -> (-x, y), or mirroring with respect to an arbitrarily rotated axis.

Finally I found applyMatrix(), which can do this (though some better documentation for the 2D case would be nice, e.g. explain that it takes 6 parameters, and not 9), but the documentation states that:

Quote:
This is very slow because it will try to calculate the inverse of the transform, so avoid it whenever possible.

My question is:  Why is it necessary to invert the matrix?  I can't see why it is necessary to have both the matrix and its inverse.  If only the inverse is needed, then why not provide a function that takes the inverse as its argument, so that numerical inversion can be avoided at runtime?

Any explanations or pointers to documentation would be welcome!

EDIT:  Since there are no replies yet, let me clarify a little bit.  First I must say that I know nothing about computer graphics, only a little bit of mathematics.  If I understand correctly, before anything is plotted, all (x, y) coordinates are transformed by multiplying the vector (x, y, 1) with a 3*3 matrix to get (x', y', 1).  This simple operation doesn't require the inverse of the transformation matrix.  So where is the inverse used?
Re: About applyMatrix()
Reply #1 - Jan 19th, 2008, 2:30pm
 
Is there really no one who knows the answer to this question?
Re: About applyMatrix()
Reply #2 - Jan 20th, 2008, 12:42pm
 
You might not need any math at all. If what you're looking to do is draw at an opposite position, the correct sequence of translate/rotate and then scale negative should do the trick.

If you then need points from that location you can use modelXYZ methods to get them.
Re: About applyMatrix()
Reply #3 - Jan 20th, 2008, 2:45pm
 
mflux wrote on Jan 20th, 2008, 12:42pm:
If what you're looking to do is draw at an opposite position, the correct sequence of translate/rotate and then scale negative should do the trick.

Scale negative!  That's it!  Thank you! Cheesy

But there are still some linear transformations that can only be done with applyMatrix(), like skewing.  And I'm still curious about why the matrix inversion is necessary Smiley  (not that the answer would allow me to do something special---I'm just curious).
Re: About applyMatrix()
Reply #4 - Jan 21st, 2008, 9:55am
 
[removed]
Re: About applyMatrix()
Reply #5 - Jan 21st, 2008, 11:29am
 
an inverse matrix is the matrix to transform a vertex V' back to V.

i myself have my own matrix & vector classes that handle computations for me.
Page Index Toggle Pages: 1