Calculating pose in terms of Euler angles for a plane using direction vectors.
I'm trying to find the pose of a rectangular plane in 3D space. I have two orthogonal vectors a
and b
that lie on the plane and centered at origin.
I take the cross product of the two and get another vector c
. I compute the norm of the vectors a
, b
, and c
and calculate the Euler angles using the following equations:
roll = tan^-1(bk/ck)
pitch = sin^-1(ak)
yaw = tan^-1(aj/ai)
Here, i
, j
, and k
represent the components along X
, Y
, and Z
axes.
Now, during the in-plane rotation (when the plane is rotated along Z
axis), if the plane is rotated towards the right it outputs the correct pose, but when it's rotated left or flipped it gives the wrong pose (verified in rViz).
I'm wondering whether there are any limitations of calculating Euler angles like this or maybe my calculations are wrong?
Edit:
I have added the following images for better understanding. The blue axis should point towards the camera, when I rotate the book left-ward, the blue-green plane rotates around red axis.