com.drismo.logic
Class AccelerationHandler.MAQueue

java.lang.Object
  extended by com.drismo.logic.AccelerationHandler.MAQueue
Enclosing class:
AccelerationHandler

private static final class AccelerationHandler.MAQueue
extends java.lang.Object

An inner static class used to remove noise from the acceleration values. Keeps a simple FIFO queue of N acceleration values, used to filter out noise using the Weighted/Exponential Moving Average algorithm.


Field Summary
private  java.util.LinkedList<float[]> list
          The queue of vectors.
private  int N
          N elements in the queue.
 
Constructor Summary
private AccelerationHandler.MAQueue()
           
 
Method Summary
private  float[] getEMAValues()
          Calculates the EMA value of the element i in the queue, based on the Exponential Moving Average algorithm.
 float[] getWMAValues()
          Calculates the WMA value of the element i in the queue, based on the Weighted Moving Average algorithm.
 void put(float[] v)
          Puts the acceleration vector in the FIFO queue, and removes excessive vectors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

N

private final int N
N elements in the queue.

See Also:
Constant Field Values

list

private java.util.LinkedList<float[]> list
The queue of vectors.

Constructor Detail

AccelerationHandler.MAQueue

private AccelerationHandler.MAQueue()
Method Detail

put

public void put(float[] v)
Puts the acceleration vector in the FIFO queue, and removes excessive vectors.

Parameters:
v - The XYZ acceleration vectors.

getWMAValues

public float[] getWMAValues()
Calculates the WMA value of the element i in the queue, based on the Weighted Moving Average algorithm.

Returns:
The weighted moving average value of the element i.

getEMAValues

private float[] getEMAValues()
Calculates the EMA value of the element i in the queue, based on the Exponential Moving Average algorithm.

Returns:
The exponential moving average value of the element i.