You can definitely calculate Pitch and Roll from accelerometer data, but Yaw requires additional information (of course, maybe a gyroscope, but maybe a compass).
As an example, consider Hungry Shark for iOS . Based on how their ui tilt calibration works, I'm sure they use an accelerometer instead of a gyroscope.
In addition, here are some formulas I found in a blog post from Taylor-Robotic for calculating pitch and pitch:
Now that we have 3 outputs, expressed in g, we must be able to calculate the pitch and roll. This requires two more equations.
pitch = atan (x / sqrt(y^2 + z^2)) roll = atan (y / sqrt(x^2 + z^2))
This will result in pitch and roll in radians, to convert them into we multiply by 180, then divide by PI.
pitch = (pitch * 180) / PI roll = (roll * 180) / PI
The thing I'm still looking for is how to calibrate the pitch and clip values โโdepending on how the user holds the device. If I canโt figure it out soon, I can open a separate question. Good luck
source share