Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transform device orientation to world frame in objective c

I'd like to transform the yaw, pitch and roll of the iPhone from the body frame to the world frame, i.e. azimuth, pitch and roll. On Android this is easily done with the SensorManager.remapCoordinateSystem(), SensorManager.getOrientation methods as detailed here: http://blog.mysticlakesoftware.com/2009/07/sensor-accelerometer-magnetics.html

Are similar methods available for the iPhone or can someone point me in the right direction how to do this transformation?

Thanks

like image 517
dap Avatar asked Oct 15 '10 15:10

dap


1 Answers

The accelerometer is good enough to get gravity direction vector in device coordinate system. That is in case when device calms down.

The next step for full device orientation is to use CLLocationManager and get the true north vector in device coordinate system. With the normalized true north vector and gravity vector you can easily get all other directions using the dot and cross vectors product.

like image 140
Krešimir Prcela Avatar answered Oct 23 '22 22:10

Krešimir Prcela