Author Topic: Remap coordinates from Android rotation vector sensor  (Read 2485 times)

Offline billda

  • byte
  • *
  • Posts: 12
    • View Profile
Remap coordinates from Android rotation vector sensor
« on: August 07, 2014, 03:00:55 pm »
Hi, I am trying to make a simple app when user tilt device and model in screen is rotated .. I've found some demos here in forum but I cannot make it work so i started from scratch. I have sucessfully implemented it, object is rotating but I have problem with coordinate system. I cannot find the right way how to convert between android one and jPCT one .. I am using sensor for Rotation vector and its returning quaternion describing rotation .. Then I am using built-in function to create rotation matrix from this quaternion .. and i am trying this matrix remap and use on my model.

Here is my code: http://pastebin.com/Z7cVVXER and here is apk demo of my app: https://www.dropbox.com/s/srcdb1j4idpyzls/app-debug.apk (large size is because of models and other stuff in app)


I tried to use only gyroscope data.. I swapped rotation angle around y and z axes and it was working fine with remap from y to z. But if i tried to compute quaternion manually by integrating as here http://developer.android.com/guide/topics/sensors/sensors_motion.html#sensors-motion-gyro it works but if I shake device or rotate very quickly it made a huge error. Approach with rotation sensor doesnt have this kind of error, but i cant simply swap axes.

If someone of you have any idea how to make it work, I will be very happy. Thanks

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Remap coordinates from Android rotation vector sensor
« Reply #1 on: August 07, 2014, 05:13:01 pm »
You can try to set the matrix in jPCT exactly as your other matrix is and than call Matrix.transformToGL(). If the Android matrix is in OpenGL format, this should actually do the trick.