I'd like to get accelerometers on Android and have them on the earth coordinate system, just like on this topic Acceleration from device's coordinate system into absolute coordinate system or here Transforming accelerometer's data from device's coordinates to real world coordinates but these solutions don't work for me. I'm working on Processing. The project is simply to track the phones accelerations in space, no matter how it is (standing, on the side...). I'm new to Android too. I'd appreciate your help! Thank you.
Edit : I don't need the phones exact position, only accelerations.
I finally worked it out! I combined 2 previous answers, here is the code :
monSensorManager.getRotationMatrix(Rotate, I, gravity_values, mag_values);
float[] relativacc = new float[4];
float[] inv = new float[16];
relativacc[0]=lin_values[0];
relativacc[1]=lin_values[1];
relativacc[2]=lin_values[2];
relativacc[3]=0;
android.opengl.Matrix.invertM(inv, 0, Rotate, 0);
android.opengl.Matrix.multiplyMV(earthAcc, 0, inv, 0, relativacc, 0);
1) Get phone unit vector in earth coordinates 2) Invert matrix to get earth unit vector in phone coordinates 3) Multiply phone acceleration by unit vector to transform phone coordinates to earth coordinates. Thank you all for your help!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With