Low pass filter on iphone accelerometer.

Hello guys, I have to filter out my iPhone,s noisy values which i get from the accelerometer.
so i got a sample code from unity,s website.

var AccelerometerUpdateInterval : float = 1.0 / 60.0;
var LowPassKernelWidthInSeconds : float = 1.0;

private var LowPassFilterFactor : float = AccelerometerUpdateInterval / LowPassKernelWidthInSeconds; // tweakable
private var lowPassValue : Vector3 = Vector3.zero;
function Start () {
	lowPassValue = Input.acceleration;
}

function LowPassFilterAccelerometer() : Vector3 {
	lowPassValue = Mathf.Lerp(lowPassValue, Input.acceleration, LowPassFilterFactor);
	return lowPassValue;
}

here i get an error on Mathf.Lerp function. it says Mathf.Lerp takes the parameters (float, float, float). so what else should i use instead of this ?

any help will be appreciative.

The variables lowPassValue and Input.acceleration are both of type Vector3. You’re passing Vector3, Vector3, float to a function that takes float, float, float. That’s why it’s failing.

If my hunch is correct, it looks like you’re using the code that’s also available in this forum thread:

http://forum.unity3d.com/threads/15029-Iphone-Shaking

Notice that the lerp function used is Vector3.Lerp, used to linearly interpolate between two vectors. You’re using Mathf.Lerp, which interpolates between floating point numbers.

I just posted a topic on this, it seems like the docs have a typo in it?