views:

485

answers:

2

In reviewing: http://developer.android.com/reference/android/graphics/Canvas.html

I'm wondering

translate(): "preconcat the current matrix with the specified translation" -- what does this mean?

I can't find a good definition of "preconcat" anywhere on the internet! The only place I can find it is in the Android Source - I'm starting to wonder if they made it up? :)

I'm familiar with "concat" or concatenate, which is to append to, so what is a pre-concat?

+4  A: 

When working with matrices, the word concatenation refers to multiplication.

Since matrix multiplication is not commutative, there is a separate word for backwards multiplication.
Pre-concatenating a to b means setting a = b × a. (As opposed to a = a × b, which will give a different matrix)

SLaks
Thank you. My question was in the context of the Android Canvas however and I'm having a hard time making the connection between the canvas and the matrix?
Brad Hein
@Brad: The canvas maintains a transform matrix; `translate` manipulates it.
SLaks
The canvas maintains a matrix and the canvas is manipulated by methods which are well defined in OpenGL. A great source of relevant definitions is: http://gpwiki.org/index.php/OpenGL:Tutorials:Theory
Brad Hein
A: 

For us newbies and with respect to the Android implementation and verbiage: What effects could be seen by "preconcatenation" of a matrix with the current matrix of the canvas? (When would you use this and for what purpose)?

thanks, Jim

JimSchumacher
Any change to the canvas happens as a preconcatination to the matrix. Think of it as a "state machine" (as explained in the OpenGL link above, I highly recommend you read it). All changes happen to this matrix. When it comes time to draw the view, the drawing goes through the matrix so it's drawn with all the desired translations.
Brad Hein