Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
转换Android矩阵值以查看变换属性_Android_Matrix_View_Transform - Fatal编程技术网

转换Android矩阵值以查看变换属性

转换Android矩阵值以查看变换属性,android,matrix,view,transform,Android,Matrix,View,Transform,我有一个使用View.setRotationX和View.setRotationY绕X和Y轴旋转的视图。我使用了View.getMatrix并修改了矩阵的值。我现在想将矩阵应用到视图中,但如果不在Android中使用传统的动画API,我还没有找到一个好的方法 基本上我需要的是将矩阵值转换为视图转换值。 例如: 这似乎是一种非常复杂的转换视图的方法,但我需要这样做,以便能够设置视图的x,y角坐标。有关获取一种方法的角点坐标的更多信息,请参阅我之前的帖子:如果您想使用反向矩阵变换,请使用反向矩阵变换

我有一个使用View.setRotationX和View.setRotationY绕X和Y轴旋转的视图。我使用了View.getMatrix并修改了矩阵的值。我现在想将矩阵应用到视图中,但如果不在Android中使用传统的动画API,我还没有找到一个好的方法

基本上我需要的是将矩阵值转换为视图转换值。 例如:


这似乎是一种非常复杂的转换视图的方法,但我需要这样做,以便能够设置视图的x,y角坐标。有关获取一种方法的角点坐标的更多信息,请参阅我之前的帖子:

如果您想使用反向矩阵变换,请使用反向矩阵变换,但我不知道反向矩阵如何将矩阵旋转值转换为查看可用旋转。好的,您似乎想要类似于不存在的setMatrix方法的东西?恐怕你必须像现在这样做。我认为最简单的方法是调用Matrix.getValues并映射这九个floatsy,这就是我希望一些矩阵专家能够帮助的映射:我将继续尝试找出如何映射。
float[] src = new float[]{0, 0, view.getWidth(), 0, 0, view.getHeight(), view.getWidth(), view.getHeight()};
float[] dst = new float[8];

Matrix matrix = view.getMatrix();
matrix.mapPoints(dst, src);
dst[7] = NEW_Y_COORD_OF_CORNER;
matrix.setPolyToPoly(src, 0, dst, 0, dst.length >> 1);
//The matrix is now changed but the View is not.

So i would like to get rotation and translation of the Matrix to apply it back to the View:

float newRotationX = convertMatrixRotationToViewRotationX(matrix); //method i need
float newRotationY = convertMatrixRotationToViewRotationY(matrix); //method i need

float newTranslationX = convertMatrixRotationToViewTranslationX(matrix); //method i need
float newTranslationY = convertMatrixRotationToViewTranslationY(matrix); //method i need

view.setRotationY(newRotationX);
view.setRotationX(newRotationY);
view.setX(newTranslationX);
view.setY(newTranslationY);