Subsection 12.6.6 Full Orientation from Three Axes (AN-1057)
The two-axis arctangent gives one tilt angle. AN-1057 (p. 7, Equations 11–13) extends this to a full orientation: measure each axis’s angle against the horizon using the other two axes as the reference,
\begin{equation*}
\theta = \tan^{-1}\!\left(\frac{A_x}{\sqrt{A_y^2 + A_z^2}}\right),\qquad
\psi = \tan^{-1}\!\left(\frac{A_y}{\sqrt{A_x^2 + A_z^2}}\right),\qquad
\varphi = \tan^{-1}\!\left(\frac{\sqrt{A_x^2 + A_y^2}}{A_z}\right)
\end{equation*}
where θ and ψ are the x and y axes’ angles above the horizon and φ is the angle between the gravity vector and the z axis. Because each is an arctangent of a ratio of accelerations, the two-axis benefits carry over: constant sensitivity, and validity at every orientation of the sensor. This is the route for Lab 7’s optional Going Further.
On quadrants: a plain arctangent only returns angles in a half circle, because it cannot tell \((+A_x, +A_y)\) from \((-A_x, -A_y)\text{:}\) the ratio is the same.
atan2(ax, ay) takes the two values separately, looks at both signs to pick the correct quadrant, and returns an angle over the full circle, from −π to π (in radians; multiply by 180/π for degrees). It also handles ay = 0, where the plain ratio would divide by zero.
