SnapGames
SnapGames

Reputation: 375

How are the values of android.graphics.Matrix used?

I am trying to understand how the 9 values in the android.graphics.Matrix class are used to render something (specifically a Bitmap).

I saw the defines for the 9 indices into the value array, however the naming convention did not seem to make much sense to me.

I have my own orientation system that I am using for all my objects in my engine. For me an orientation consists of a position, a forward vector, and a left vector.

I am trying to figure out how to take these 3 pieces of data (which are already mapped to screen space) and create an android.graphics.Matrix that will render my object's bitmap as I would expect.

Any help would be appreciated.

Thanks

Upvotes: 10

Views: 8184

Answers (1)

SnapGames
SnapGames

Reputation: 375

I eventually figured out the documentation. For anyone who was confused about the wording like I was, here is another explanation:

[0,0 0,1 0,2]

[1,0 1,1 1,2]

[2,0 2,1 2,2]

=

[MSCALE_X MSKEW_X MTRANS_X]

[MSKEW_Y MSCALE_Y MTRANS_Y]

[MPERSP_0 MPERSP_1 MPERSP_2]

=

[scale.x diagonal.x pos.x]

[diagonal.y scale.y pos.y]

[0.0f 0.0f 1.0f]

Upvotes: 24

Related Questions