Android Linear Acceleration, calculating a trajectory
<p>I'd like to use my accelerometer in my car and with the accelerometer values, draw a trajectory in excel or any other platform with the origin in the first position value, that is the beginning of the path.</p>

<p>How can I achieve this? Please give me details I don't have any physics notion.</p>

<p>Please help, thanks in advance.</p>

<p>PS: I already programmed the SensorListener...</p>

<p>I have this for instance:</p>

<pre><code>@Override
public void onSensorChanged(SensorEvent event){
    if(last_values != null){
        float dt = (event.timestamp - last_timestamp) * NS2S;
        for(int index = 0 ; index &lt; 3 ; ++index){
            acceleration[index] = event.values[index];
            velocity[index] += (acceleration[index] + last_values[index])/2 * dt;
            position[index] += velocity[index] * dt;
        }
        vxarr.add(velocity[0]);
        vyarr.add(velocity[1]);
        vzarr.add(velocity[2]);
        axarr.add(acceleration[0]);
        ayarr.add(acceleration[1]);
        azarr.add(acceleration[2]);
    }
    else{
        last_values = new float[3];
        acceleration = new float[3];
        velocity = new float[3];
        position = new float[3];
        velocity[0] = velocity[1] = velocity[2] = 0f;
        position[0] = position[1] = position[2] = 0f;
    }
    xarr.add(position[0]);
    yarr.add(position[1]);
    zarr.add(position[2]);
    tvX.setText(String.valueOf(acceleration[0]));
    tvY.setText(String.valueOf(acceleration[1]));
    tvZ.setText(String.valueOf(acceleration[2]));
    last_timestamp = event.timestamp;
}
</code></pre>

<p>but when I draw a circle with my phone I got this:</p>

<p><a href="https://i.stack.imgur.com/zaMEu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zaMEu.png" alt="enter image description here"></a></p>

<p>Sometimes I have just only negative values and sometimes I have just positive values, I never have negative AND positive values in order to have circle. </p>