I'm trying to rotate a model (terrain) situated at (X,Y,Z)=(0,0,0)
of my OpenGL-World. +X
is east, -Z
is north, +Y
is altitude. View is looking to -Y
because the device Euler angles are (0°,0°,0°)
while the device is lying on the table pointing north.
The Problem:
I need to switch the axes of my device to change the measured angle device -y
to device z
.
Currently rotation around the device x-axis
works (results in rotation around World X-axis
).
But rotation around device y
leads to a rotation around World Y
instead of World -Z
and rotation around device z
to rotation around World Z
instead of World Y
.
By now I'm running out of ideas how to solve this. Anybody who could give me a hint please?
(OpenGL) (Device)
^ +Y-axis ^ +z-axis
* *
* *
* * ^ +y-axis (North)
* * *
* * *
* * *
************> + X-axis ************> +x-axis
*
*
v +Z-axis (Minus North)
What I've tried so far:
- Using Euler angles from
SensorManager.getOrientation
and switching angles works fine, though I get into gimbal lock close to pitch 90 deg. So I'm in search for another solution (theSensorManager
rotation matrix or quaternions). SensorManager.remapCoordinateSystem
in almost every possible constellation -> doesn't help- Changing cols/rows of my rotation matrix from
SensorManager.getRotationMatrix
-> doesn't help