Search Unity

Rotation of acceleration

Discussion in 'Physics' started by dh2000, Mar 27, 2015.

  1. dh2000

    dh2000

    Joined:
    Jun 19, 2014
    Posts:
    6
    I am using accelerometer data from android device in my project. My problem is that when you perform the same movement, accelerometer gives different results depending on device rotation. So i need to align coordinate system of device with real world coordinates.

    For example, when the device is moved vertically (in other words - in direction of gravity), i need to get readings in the same axis when device is facing down, forward, landscape or portrait. But other 2 axis need to stay aligned with device. So when you move device away from you (or sideways) the output won't get influenced when you change your heading.

    I have working solutioun using Sensor.orientation from GyroDroid, and it works well on tablet in landscape mode. But since it is Vector3 it doesn't work in portrait (i think it is due to gimbal lock). I tried using Sensor.orientationQuaternion but i didn't find solution so far.

    Can anyone help me?
    Thank you very much!