Hi everyone: I wanna translate the return values of Sensor.TYPE_ACCELEROMETER to the world coordinate system,I did this in this way:
public void onSensorChanged(SensorEvent event) { if (event.accuracy == SensorManager.SENSOR_STATUS_UNRELIABLE) return; switch (event.sensor.getType()) { case Sensor.TYPE_MAGNETIC_FIELD: mags = event.values.clone(); break; case Sensor.TYPE_ACCELEROMETER: accels = event.values.clone(); break; case Sensor.TYPE_ORIENTATION: orent = event.values.clone(); break; } if (mags != null && accels != null) { SensorManager.getRotationMatrix(inR, I, accels, mags); for(int k=0;k<3;k++) { a[0] = accels[0]*inR[0]+accels[1]*inR[1]+accels[2]*inR[2];//ax a[1] = accels[0]*inR[3]+accels[1]*inR[4]+accels[2]*inR[5];//ay a[2] = accels[0]*inR[6]+accels[1]*inR[7]+accels[2]*inR[8];//az .... } But I find I move the phone in any direction the ax and ay will all be 0,and the az is some value I can't understand, so is any body meet the same problem,or the return matrix of the getrotationmatrix() is really inaccurate when there is another accelerate besides g(gravity) so I can translate the accelerate in this way. any help will be very appreciated. Saka -- 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