|
|
|
|
|
by manchego
905 days ago
|
|
My wife has had to listen to me complain for the last week about what a pain it is to get the absolute orientation of an iPhone from the browser. On Android you can use AbsoluteOrientationSensor or deviceorientationabsolute event. These will provide a quaternion or Euler angles describing how to rotate the device from the default orientation (flat on the ground, screen up, with the top pointing north) to its current orientation. The situation on the iPhone has almost reduced me to tears. As far as I can tell, it only provides Euler angles relative to some implementation defined reference frame, along with the actual compass heading. In practice, the Euler angles given are absolute with respect to gravity, but always treat north as the direction the phone was pointed when the first sensor reading took place. To deal with this, you can use the actual compass heading to rotate the relative orientation to the absolute orientation. But this will have problems near the poles, as the Euler angles and heading will give conflicting values. Beyond this the compass heading field is really weird. If you want to experience its behavior for yourself, take the iPhone compass app and starting from flat, rotate the phone 360 degrees through the pitch axis. Notice at what points the heading flips between its start heading and start heading+180. I bet it will surprise you! |
|