So I previously asked a question more about what ind of sensor to use for the application I'm building. After some research I know now that it's the rotation vector that I want to use for I want to be able to move a virtual cube on my tablet according to the orientation of the device.
Let's imagine the tablet is in a given orientation O1 and therefore the orientation vector gives me a rotation matrix OM1 Let's imagine now that I lock the screen and move the tablet and rotate it so that it is afterwards, just before unlocking the screen in a given Orientation O2 and the orientation vector (which is stopped during the locked screen) will give when the screen is back on a rotation matrix OM2.
I want my virtual cube to remain in the position it was before the screen was locked when I unlock it again.
Of course for that I have already set up a rotation matrix in my code that keeps in memory the rotation matrix when the system pauses (i.e when I lock the screen). So that when the screen is back the cube is in the right position.
However, when I move my tablet again (rotation) I want the cube to respond to these rotations according to the orientation matrix OM1 it had before the screen was locked and not just based on the orientation matrix that is given at any moment by the rotation vector sensor.
I am guessing that I need to compute somehow a differenceMatrix that will give me how to go from OM1 to OM2. But even with that I don't get what I want yet.
Here are the few operations i've tried:
if(hasLocked == true){
Matrix.transposeM(transposed,0,mRotationLock,0); //mRotationLock is the rotation matrix that I save when the screen goes off
Matrix.multiplyMM(mDifferenceRotation, 0, transposed, 0, mRotationMatrix, 0);
System.arraycopy(mDifferenceRotation,0,mRotationMatrix,0,16);
}