Android Matrix,getValues()返回什么?

时间:2010-07-08 10:02:45

标签: android path matrix

我无法计算下面代码的返回值pMeasure = PathMeasure,m = Matrix,distCount是沿路径的距离

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

float [2]& float [5]是位置x& y分别但我无法弄清楚其余的

任何帮助再次受到赞赏。

2 个答案:

答案 0 :(得分:12)

取自Matrix class documentation

  

public static final int MPERSP_0
  常数值:6(0x00000006)

     

public static final int MPERSP_1
  常数值:7(0x00000007)

     

public static final int MPERSP_2
  常数值:8(0x00000008)

     

public static final int MSCALE_X
  常数值:0(0x00000000)

     

public static final int MSCALE_Y
  常数值:4(0x00000004)

     

public static final int MSKEW_X
  常数值:1(0x00000001)

     

public static final int MSKEW_Y
  常数值:3(0x00000003)

     

public static final int MTRANS_X
  常数值:2(0x00000002)

     

public static final int MTRANS_Y
  常数值:5(0x00000005)

答案 1 :(得分:7)

Android Matrix使用skia及其行主要意义索引如下

0  1  2  
3  4  5
6  7  8

我对比OpenGL使用像这样的索引

0  3  6
1  4  7
2  5  8

关于矩阵位置,“含义”是相同的。

a  b  tx
c  d  ty
0  0   1

a,b,c,d编码规模&同时轮换。 tx / ty编码翻译。如果你做m.getValues(vals);那么vals [2] == tx,vals [5] == ty,剩下的就是直截了当。提取翻译的最佳方法是制作一个载体

float[] point = {0, 0};

然后映射它并查看它的结束位置和那是你的翻译(正好是(tx,ty)。在极少数情况下它不是

获得比例尺第二点

float[] point2 = {1, 0};

现在取差值rel =(point-point2)并获得该向量的长度,这就是你的比例。要提取旋转,请将rel标准化,并且很容易获得它的标准角度。