Par*_*unt 3 java android matrix
我需要能够设置矩阵的旋转而不是添加它.我相信设置旋转的唯一方法是知道矩阵的当前旋转.
注意:matrix.setRotate()不会这样做,因为矩阵需要保留其信息.
float[] v = new float[9];
matrix.getValues(v);
// translation is simple
float tx = v[Matrix.MTRANS_X];
float ty = v[Matrix.MTRANS_Y];
// calculate real scale
float scalex = v[Matrix.MSCALE_X];
float skewy = v[Matrix.MSKEW_Y];
float rScale = (float) Math.sqrt(scalex * scalex + skewy * skewy);
// calculate the degree of rotation
float rAngle = Math.round(Math.atan2(v[Matrix.MSKEW_X], v[Matrix.MSCALE_X]) * (180 / Math.PI));
Run Code Online (Sandbox Code Playgroud)