0

I am developing an indoor location app with Google's Project Tango device, and I want the UI to display the device orientation with regard to the ADF map.

For this purpose I am accessing the Z axis rotation information from TangoPoseData, and try to convert the rotation data back to an angle in degrees.

The rotation information in TangoPoseData being defined as follows,
z = RotationAxis.z * sin(RotationAngle / 2)

my code looks like this:

//Sine value of the angle
double tangoRotationZsin = pose.rotation[2];

//Convert the sine value into a angle in radians
double tangoRotationZRad = 2*Math.asin(tangoRotationZsin);

//Convert to an angle in degrees
double tangoRotationZDeg = tangoRotationZRad * 180/Math.PI;

Problem:

The angle value in degrees (tangoRotationZDeg) should range from -180 to 180, but even if I rotate the device by 360 degrees several times on the Z axis, the angle ranges only from -120 to 120 degrees (or sometimes between -110 to 110 degrees).

What am I missing?
I guess that the problem has something to do with the "RotationAxis.z" factor in TangoPoseData which I assume equal to 1 in my code, but not sure.

Thank you for any help!

Community
  • 1
  • 1
  • Have you deliberately ruled out the use of quaternions ? – Mark Mullin Jan 22 '15 at 03:18
  • I am not developing a 3D app, but a 2D map much like Google Maps where a dot indicates the user position. My goal is to rotate this dot around the Z axis to indicate the user orientation. This dot is an Android bitmap rotated by the Matrix.postRotate(float degrees) function, and unfortunately this function requires an angle in degrees, not a quaternion (I am developing a Android app in Java, not using Unity). So I have no choice but trying to compute the original angle back from Pose data... – Jocelyn Cambria Jan 22 '15 at 03:51

1 Answers1

0

Look at this -- SO Post on extracting yaw from a quaternion - note that the TangoPoseData rotation is a quaternion value, not a set of Euler angles

Community
  • 1
  • 1
Mark Mullin
  • 1,340
  • 1
  • 9
  • 21