see also, the wiki answers (scroll slightly down the page) ... http://answers.unity3d.com/questions/15215/unity-3d-and-augm...
[1] threeVR, an orientation-aware Virtual Reality controller built on top of three.js: https://github.com/richtr/threeVR
[2] Full-Tilt, device orientation + motion detection, normalization and conversion library: https://github.com/adtile/Full-Tilt
[3] Compass demo, by the same person as Full-Tilt: https://richtr.github.io/Marine-Compass/
[4] Mirror of some of the older Full-Tilt demos: https://jbmoelker.github.io/Full-Tilt/examples/
(There was also a good 360-degree VR demo before Full-Tilt changed urls, it used to be also hosted under richtr.github.io, I can't find it anymore but I'll try... this was a distinct but similar demo to [1] and it had a beach end-of-pier scene)
[5] gyronorm.js, to correct some DeviceOrientation bugs: https://github.com/dorukeker/gyronorm.js
[6] An MDN blog post on DeviceOrientation: https://developer.mozilla.org/en-US/Apps/Fundamentals/gather...
As far as AR goes the math needed to do what they do is pretty trivial.
I Imagine that if you are in a room that's already mapped then you can handler all those things, but if it is a random location where you can't know which objects there are then is a bit more complicated.
Thanks!