Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: how do I do the opposite of 'Matrix.mapPoints(float[] points)'?

If I have a point and a Matrix:

float point[] = new float[]{x,y};
Matrix matrix = new Matrix();

and call:

matrix.mapPoints(point);

how could I reverse the effects that matrix.mapPoints(point) has on point?

This isn't the actual application that I will use the answer for, but an answer for this will would work for what I need.

Thanks for any help.

like image 918
raystubbs Avatar asked Oct 10 '14 21:10

raystubbs


1 Answers

If you don't want yourMatrix to change

 Matrix inverseCopy = new Matrix();
 if(yourMatrix.invert(inverseCopy)){
      inverseCopy.mapPoints(transformedPoint);
      //Now transformedPoint is reverted to original state.
 }

If you want yourMatrix to change

 if(yourMatrix.invert(yourMatrix)){
      yourMatrix.mapPoints(transformedPoint);
      //Now transformedPoint is reverted to original state.
 }

matrix.invert() returns false if the matrix cannot be inverted. If your matrix cannot be inverted there is no way to revert your points to original state.

like image 109
Durgadass S Avatar answered Sep 27 '22 22:09

Durgadass S