I wrote a test application that registers with the SensorManager as a SensorListener to receive orientation updates and rotates a unit cube with respect to the current orientation. This is mostly a modified version of CubeRenderer from the API examples.
In a fixed position (i.e., the phone on the desk) the cube wobbles about 5 degrees with respect to each angular parameter. When rotating the phone, the sensor is even less accurate. I've tried setting the orientation both with glRotate and with an explicit matrix formulation of the XYZ Eulerian angles, where the angular measure is in radians, as, float[] cg2 = new float[16]; cg2[0] = (float)(Math.cos(_pitch) * Math.cos(_roll)); cg2[1] = (float)(-Math.sin(_azimuth) * Math.sin(_pitch) * Math.cos(_roll) - Math.cos(_azimuth) * Math.sin(_roll)); cg2[2] = (float)(-Math.cos(_azimuth) * Math.sin(_pitch) * Math.cos(_roll) + Math.sin(_azimuth) * Math.sin(_roll)); cg2[3] = 0.0f; cg2[4] = (float)(Math.cos(_pitch) * Math.sin(_roll)); cg2[5] = (float)(-Math.sin(_azimuth) * Math.sin(_pitch) * Math.sin(_roll) + Math.cos(_azimuth) * Math.cos(_roll)); cg2[6] = (float)(-Math.cos(_azimuth) * Math.sin(_pitch) * Math.sin(_roll) - Math.sin(_azimuth) * Math.cos(_roll)); cg2[7] = 0.0f; cg2[8] = (float)(Math.sin(_pitch)); cg2[9] = (float)(Math.sin(_azimuth) * Math.cos(_pitch)); cg2[10] = (float)(Math.cos(_azimuth) * Math.cos(_pitch)); cg2[11] = 0.0f; cg2[12] = 0.0f; cg2[13] = 0.0f; cg2[14] = -10.0f; cg2[15] = 1.0f; gl.glLoadMatrixf(cg2, 0); Both, gives this same result. Does this behavior sound like it is correct? If so, is there any way to improve upon it other than doing a moving average of the last $n$ orientation updates? Thanks, --- Joshua Shaffer PhD Student Dept. of Materials Science Drexel University 215-895-2327 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---