Search code examples
windows-phone-7windows-phone-7.1accelerometer

How to find device position change using accelerometer?


I am designing a Windows Phone 7 project where I need to determine position changes of the device. I tried to use accelerometer, but it gives info on current orientation of my phone and I don't know how to convert this data to position delta. Here is some example code:

void acc_CurrentValueChanged(object sender, SensorReadingEventArgs<AccelerometerReading> e)
{
    AccelerometerReading newdata = e.SensorReading;
    Vector3 vect = newdata.Acceleration - data.Acceleration;
    //what comes here???
}

The method above is called when accelerometer data is changed. But I don't know how to convert this data to position change of a device (i.e. I move my phone in X direction)


Solution

  • You can't do it.

    You get position by integrating the linear acceleration twice but the error is horrible. It is useless in practice.

    See the above linked answer to get some ideas what you actually can do.