Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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.

Honesly, I don't know.. I bet these values are reserved, and the reason why they are present perhaps is to complete the matrix. Here you will find more info on this topic: mobiledevelop.blogspot.com/2009/02/… – Andrejs Cainikovs Jul 14, 2010 at 13:05 Android uses skia and I checked the source code for androids matrix class, in its C++ core, it simply glues Matrix, with SkMatrix. The matrix is 3x3 row major. Because of this MSCALE_X/Y is not actually scale. As long as no rotations are involved it is scale. If matrix encodes a rotation you need to do extra math to calculate the scale. MPERSP is used to calculate the "z" coordinate, by default z=1. If z !=1 then x=x/z; y=y/z; z=z/z=1. In general you don't need to worry about it z. It's just like opengl 4x4 for 3D, except on android its 3x3 for 2D – over_optimistic Mar 22, 2013 at 14:49

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.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.