Accelerometer Low Pass Filter Smoothing

天大地大妈咪最大 提交于 2019-12-24 06:38:01

问题


I am using the device accelerometer and try to smooth the Accelerometer Data CMAcceleration.

I am doing this with help of this code:

-(void)proccessAccelerometerData:(CMAcceleration)accelData {
    currentAccelX = (kUpdateInterval * accelData.x) + ((1.0 - kUpdateInterval) * currentAccelX);
    currentAccelY = (kUpdateInterval * accelData.y) + ((1.0 - kUpdateInterval) * currentAccelY);
}

Which currentAccelX and currentAccelY is the last accelerometer x and y data.

Now, I have the smooth x and y values, What is my value of x or y to determine id the user move the device left/right/up/down?

Just to make things more clear, for example, let's say that I have 4 buttons, one for each direction left/right/up/down and I want to determine which direction the user user swipe the device? (not swipe gesture). Thanks in advance!


回答1:


Assuming you hold the device in portrait orientation, the x-Axis indicates the movement to the left and right (positive x is to the right and negative x to the left).
The y-Axis indicates the movement of the device up and down (positive y is upwards and negative y is downwards).
The z-Axis indicates the movement of the device forwards and backwards (positive z is towards the user and negative z is away from the user).
There is an info graphic by Apple: developer.apple.com



来源:https://stackoverflow.com/questions/25591310/accelerometer-low-pass-filter-smoothing

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