Android Matrix 笔记

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lylwo317/article/details/86169357

Android Graphic Matrix表达式

一. 如何计算?

例子:

Matrix matrix = new Matrix();
float[] points = new float[] { 10.0f, 10.0f };
matrix.setScale(2f, 3f);
matrix.preTranslate(8.0f, 7.0f);
matrix.postTranslate(18.0f, 17.0f);
matrix.mapPoints(points);
//从上往下。最后的prexxx先执行,所有的prexxx执行完再到第一个postxxx执行,一直执行到最后一个postxxxx
//所以用文字描述是,先对原始坐标点(10,10)进行 Translate(8,7) 位移,
//然后再对中间坐标点(18,17)进行Scale(2,3)放大,最后再次对中间坐标点(36,51)进行
//Translate(18,17) 操作,就得到了最后的坐标点(54,68)。

数学表达式如下

[ 1 0 18 0 1 17 0 0 1 ] × [ 2 0 0 0 3 0 0 0 1 ] × [ 1 0 8 0 1 7 0 0 1 ] × [ 10 10 1 ] = [ 54 68 1 ] \left[ \begin{matrix} 1 & 0 & 18 \\ 0 & 1& 17 \\ 0 & 0 & 1 \end{matrix} \right] \times \left[ \begin{matrix} 2 & 0 & 0 \\ 0 & 3 & 0 \\ 0 & 0 & 1 \end{matrix} \right] \times \left[ \begin{matrix} 1 & 0 & 8 \\ 0 & 1 & 7 \\ 0 & 0 & 1 \end{matrix} \right] \times \left[ \begin{matrix} 10 \\ 10 \\ 1 \end{matrix} \right] =\left[ \begin{matrix} 54 \\ 68 \\ 1 \end{matrix} \right]
<–<--<–<—post n-----post2-----post 1------(原Matrix)从右往左乘(从右往左执行)------pre 1-----pre 2------pre n-------

二. 进阶参考

android matrix 最全方法详解与进阶(完整篇)

猜你喜欢

转载自blog.csdn.net/lylwo317/article/details/86169357