I'm trying to use the alpha, beta and gamma values available from the JS deviceorientation
Event object to calculate which way a smartphone camera is facing when you take a picture from a PhoneGap app.
I understand conceptually what the alpha, beta and gamma values represent, but I'm having issues with the fact that if the user takes a picture from a landscape perspective instead of a portrait perspective, the alpha value doesn't report out the true heading (i.e., direction) the camera is facing.
I'd like to have an equation that I provide the alpha, beta and gamma values to that then returns the direction (in degrees) the phone is facing so that I can then convert that to a cardinal (north/south/east/west) direction.
I found the following SO question for which the accepted answer seems to be getting at what I'm asking for, but when I compare the output of the function to what the built-in Compass app on the iPhone 6s reports out, it seems to be off by a considerable amount (i.e., about 10-15 degrees):
Calculate compass heading from DeviceOrientation Event API