4

我想在我的应用程序中使用 android 中的加速度计。在文档中给出如下:

   final float alpha = 0.8;

   // Isolate the force of gravity with the low-pass filter.

   gravity[0] = alpha * gravity[0] + (1 - alpha) * event.values[0];

但低通滤波器的工作原理如下:

    output = alpha*input + (1-alpha)*previousoutput;

我的问题是为什么我们将重力作为输入而将传感器事件作为先前的输出?它必须是其他方式。

4

1 回答 1

1

从技术上讲,它使用两个输入的线性混合:mix(α,x,y) = α * x + (1-α) * y.

现在mix(α,x,y)相当于mix(1-α,y,x). 因此,您可以根据需要反转信号,制作alpha = 0.2并且一切都将正常工作。

于 2012-10-09T14:52:43.503 回答