Low Pass Filter

Usage
This function filters out high frequency jitter caused by hardware sampling such as accelerometer output or Augmented reality marker pose output. In most cases a generic low pass filter can be used to get rid of jitter but this will not work for rotations because of the transition between 360 and 1 degrees. If this transition is not taken into account, violent movements are the result when operating at this range. To counteract this, a Quaternion.Lerp function is used.

Note that the modified output needs to be stored outside of the function as a global variable. Also, the previous value should be initialized to the current value at the first iteration to prevent jumps.

Generic Low Pass Filter
The output of this function is the modified intermediate value. The input is "targetValue", and "intermediateValueBuf" needs to be stored outside of the function as a global variable.