For an augmented reality application I am using some slam algorithm to predict the current orientation of my mobile phone.
The algorithm (LSD-Slam) supplies the current pose in form of a SE3 lie group (using Sophus::Sim3f). If I got this right, this type contains a matrix which can be interpreted as the Viewmatrix of a Camera. After initialisation, e.g. the matrix looks like this:
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
To visualize 3D Content, I use OpenSceneGraph. Fortunatley, in OSG you can set the camera position directly using a view-matrix:
camera->setViewMatrix(matrix);
Now, when I run the code things seem to work fine if I rotate around Y (roll) or Z (yaw). But when I rotate around X (pitch), my digital Camera in OSG seems to do the exact opposite of what it's supposed to to.
For example: Imagine a 3D-Model directly in front of the Camera. If I then slowly tilt the camera upwards (around X), the 3D-Model also moves upwards, while it actually should be leaving the screen at the bottom end. I tried to illustrate this behaviour with the following graphic:
Propably there is a really easy solution for this, but I just couldn't fix even after hours of trying. If I understood right, the first Columns represent the rotation around a certain Axis, so I tried inverting the single vectors, e.g. did this:
u u u 0 -u u u 0 -u -u -u 0
v v v 0 => -v v v 0 ... v v v 0
n n n 0 -n n n 0 n n n 0
0 0 0 1 0 0 0 1 0 0 0 1
While some tries really solved the Pitch-Issue, they then messed up another axis.. There always seems to be one axis wrong at least. Does anybody have a clue how i could solve this? I'd really appreciate any hints on this issue.