Calibrate UIAccelerometer?

二次信任 提交于 2019-12-06 08:18:21

I can give you some pointers. The calculation for rollingX is incorrect, it will give out values outside the range -1 - +1, you need a way to detect it hitting the limit and adjust it appropriately. Also simply offsetting one axis will not work. The accelerometer works in 3D space. In order for your calculation to work correctly the phone would always have to be 0 in the z-plane. The further into the z-plane the user rotates the phone, the smaller the readings the device will output on the x-plane. Accelerometers sense gravity, so the planes are fixed relative to this.

In order to carry out an effective calibration you will need to apply a continuous matrix transformation to all 3-axis, as you will need weighted offsets (eg as z increases, pay more attention to y rather than x etc).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!