# Derivation of yaw, pitch, roll equations for an accelerometer

I'm struggling to find a good resource that explains how roll, pitch, yaw angles are calculated from the X, Y, Z measurements of an accelerometer. I came across this document but the explanation on page 9 is still very sparse. In particular, I'm unable to understand the following 2 lines:

The accelerometer vector lies on the surface of a sphere with radius 1g. It is not therefore possible to solve for three unique values of the roll φ, pitch θ and yaw ψ angles.

Suggestion for a good book or web resource would be much appreciated.

• What about the stuff on page 10? Have you worked through the example they provide? Mar 7 '17 at 13:31
• It looks like you have found a good resource. But it says "Further details of the operation of a tilt-compensated eCompass can be found in application note AN4248" at the bottom of page 9. Mar 7 '17 at 14:22

Eqn 25 comes from Eqn 24

$$\tan \phi = \frac{\cos \theta \sin \phi}{\cos \theta \cos \phi} = \frac{G_{py}}{G_{pz}}$$

Eqn 26 is similar. But note that

$$G_{py}^2 + G_{pz}^2 = \cos^2 \theta \times (\sin^2 \phi + \cos^2 \phi) = \cos^2 \theta$$

Regarding the problematic sentence you quote: a spherical surface has only two degrees of freedom. For instance, interpret the yaw angle as longitude and pitch as latitude, leaving the roll angle undefined.

Yaw, pitch and roll are only well-defined for small angles.

For large angles, the become degenerate. For example, a 90 degree pitch up (ending pointing vertically) followed by a right-down 90 roll is the same as right-down 90 degree roll followed by a left 90 yaw.

The physics reason is a bit subtle. It takes three numbers to orient a body in space, it just turns out that body-centered pitch, roll and yaw are mathematically inconvenient for large angles.