Android Matrix,getValues() 返回什么?
我无法计算出以下代码的返回值 pMeasure = PathMeasure, m = Matrix, distCount 是沿路径
pMeasure.getMatrix(distCount, m, 0x01 | 0x02);
m.getValues(float[] values)
float[2] & 的距离float[5] 是位置 x &分别是 y,但我无法弄清楚其余部分,
再次感谢任何帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
取自 Matrix 类文档:
Taken from the Matrix class documentation:
Android Matrix 使用skia 及其行主序含义索引如下
我对比OpenGL 使用这样的索引
“含义”在矩阵位置方面是相同的。
a、b、c、d 编码比例和同时旋转。 tx/ty 编码翻译。如果你这样做 m.getValues(vals);那么 vals[2] == tx, vals[5] == ty, 其余的就很简单了。提取翻译的最佳方法是制作一个向量,
然后将其映射并查看它最终在哪里,这就是您的翻译(确切地说是(tx,ty)。在极少数情况下,它不会
获得比例图第二个点
现在采取差异rel = (point - point2) 并获取该向量的长度,这就是您的比例。要提取旋转,请标准化 rel,很容易获得它的标准角度。
Android Matrix uses skia and its row-major meaning the indices are as follows
I contrast OpenGL uses indices like so
The "meanings" are identical in regards to matrix position.
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
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
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.