I am currently trying to develop a 3D compass myself. I have been
trying for almost a week now, and still no luck. So please help me
out. This is the code I use for my orientation handler

public void onSensorChanged(int sensor, float[] values) { // azimuth
pitch roll
                if (sensor == SensorManager.SENSOR_ACCELEROMETER) {
                        direction = values[2];
                } else if (sensor == SensorManager.SENSOR_ORIENTATION) {
                        if (direction < 0) {
                                angleX = values[1];
                                angleY = -values[2];
                                angleZ = values[0];
                        } else {
                                angleX = -values[1];
                                angleY = -values[2];
                                angleZ = values[0];
                        }

                        //                      angleX = values[0];
                        //                      angleY = values[1];
                        //                      angleZ = values[2];
                }

angleX, Y and Z are the degrees I rotate my 3D object with. At first I
tried the commented code, but the object doesn't rotate around the
correct axis. But now the problem is that at a certain point the
object "jumps" from one position to another. This particularly happens
when the pitch becomes lower than -90 and thus begins to increase
while on the other hand the yaw is increased with a 180 degrees and so
is the roll.

Please tell why my code isn't working correctly and how can I fix it.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to