I am reading yaw, pitch and roll values from a mobile device. If I perform a yaw of 90 degrees and then any roll, the roll value is not changing but only the pitch value. That is because the device is always referencing to a non turning coordinate system. Therefore a turn around the z axis (yaw) of 90 degrees causes the pitch and roll readings to be "switched". Therefore lifting the iPhone at the top where the selfie camera is located is now no more changing the pitch value but the roll value as the referencing coordinate system is still the same. I can't change that programmatically.
So is there a mathematical way to turn the coordinate system with the device without loosing the turn value around for example the z-axis? I think I can do this by getting the transformation matrix and multiply it with its inverse but keeping the rotation around z. However how can I do this for combined rotations around all three axis? Because with combined rotations every element(yaw, pitch and roll) is already containing a part of the other two elements because the axis are switched with every rotation. Has anyone an idea??? Help is greatly appreciated!