gpt4 book ai didi

Android在地球坐标系上获取加速度计

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:02:36 25 4
gpt4 key购买 nike

我想在 Android 上获得加速度计并将它们放在地球坐标系中,就像这个主题一样 Acceleration from device's coordinate system into absolute coordinate system或这里 Transforming accelerometer's data from device's coordinates to real world coordinates但这些解决方案对我不起作用。我正在处理。该项目只是简单地跟踪手机在太空中的加速度,无论它是如何(站立,侧面......)。我也是安卓新手。感谢您的帮助!谢谢你。

编辑:我不需要手机的确切位置,只需要加速度。

最佳答案

我终于搞定了!我结合了 2 个以前的答案,这里是代码:

  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) 获取地球坐标中的电话单位向量2) 逆矩阵得到电话坐标中的地球单位向量3) 将手机加速度乘以单位向量,将手机坐标转换为地球坐标。谢谢大家的帮助!

关于Android在地球坐标系上获取加速度计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23701546/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com