Refer to the code below, I got 4 numbers from the Game_Rotation_Vector sensor event and what I want to achieve is to get the axis angle rotation of my phone.
eg. If I rotate the phone screen counter clock wise for 90 degress, I want to get the actual value 90deg from the sensor data.
Can anyone provide the code to convert the 4 game rotation vector values to 3 axis angle values?
The values are placed into the unit quaternion like so:
So the reverse of that is just:
But xa, xy, and xz aren't angles, they're coordinates of an axis as described in the documentation. I'm not sure what you want with these, you are likely better off trying to achieve your unstated goal with the unit quaternion directly.
The reason a unit quaternion is used is to avoid gimble lock, basically you cannot describe every possible rotation in terms of three angles, roll/pitch/yaw, for example at a certain pitch and yaw angle you can lose the ability to roll.
So one way to make use of this is to convert into a rotation matrix:
Source