# Android Matrix, what does getValues() return?

i'm having trouble working out the returned values of the below code pMeasure = PathMeasure, m = Matrix, distCount is the distance along the path

pMeasure.getMatrix(distCount, m, 0x01 | 0x02); m.getValues(float[] values)

float[2] & float[5] are position x & y respectively but i can't figure out the rest

any help once again appreciated.

## Answers

Taken from the Matrix class documentation:

public static final int MPERSP_0 Constant Value: 6 (0x00000006)

public static final int MPERSP_1 Constant Value: 7 (0x00000007)

public static final int MPERSP_2 Constant Value: 8 (0x00000008)

public static final int MSCALE_X Constant Value: 0 (0x00000000)

public static final int MSCALE_Y Constant Value: 4 (0x00000004)

public static final int MSKEW_X Constant Value: 1 (0x00000001)

public static final int MSKEW_Y Constant Value: 3 (0x00000003)

public static final int MTRANS_X Constant Value: 2 (0x00000002)

public static final int MTRANS_Y Constant Value: 5 (0x00000005)

Android Matrix uses skia and its row-major meaning the indices are as follows

0 1 2 3 4 5 6 7 8

I contrast OpenGL uses indices like so

0 3 6 1 4 7 2 5 8

The "meanings" are identical in regards to matrix position.

a b tx c d ty 0 0 1

a,b,c,d encode scale & rotation at the same time. tx/ty encode translation. If you do m.getValues(vals); then vals[2] == tx, vals[5] == ty, and the rest is straight forward. The best way to extract translation is to make a vector

float[] point = {0, 0};

Then map it and see where it ends up and that's your translation (which is exactly (tx, ty). Under rare circumstances its not

to get scale map a second point

float[] point2 = {1, 0};

Now take the difference rel = (point - point2) and get the length of that vector and that's your scale. To extract rotation, normalize rel and it's simple to get it's standard angle.