singular-ish at θ = 2π, not composable by addition
UKF error state, sigma offsets
Unit quaternion
4
no singularity, cheap composition
double cover, 1 constraint
UKF state
Euler angles (ZYX)
3
human-readable
gimbal lock, order-dependent
output roll / pitch / yaw
Rotation matrix
Columns are the body axes expressed in the world frame. RTR=I, detR=1. Inverse = transpose. Body → world: vw=Rvb.
Axis-angle
Rodrigues' formula, with [u]× the skew matrix of u:
R=I+sinθ[u]×+(1−cosθ)[u]×2
Going back: θ=arccos2trR−1, [u]×=2sinθR−RT — undefined at θ = 0 and π, the issue in from_rotm ([[Code Review - Bugs and Fixes#6. from_rotm() divides by sin θ|bug #6]]).
Matrix → quaternion
Robust (Shepperd) method: pick the largest of trR,R00,R11,R22 and divide by the square root of that, so you never divide by ~0. If trR>0:
(ukf_core.rotm_to_quat implements all four branches.)
Euler angles (ZYX)
Yaw ψ about z, then pitch θ about the new y, then roll φ about the new x:
R=Rz(ψ)Ry(θ)Rx(ϕ)
From a quaternion (same as Quaternion.euler_angles and quat_to_euler):
ϕ=atan2(2(wx+yz),1−2(x2+y2))
θ=arcsin(2(wy−zx))
ψ=atan2(2(wz+xy),1−2(y2+z2))
Clip the arcsin argument to [−1, 1].
Gimbal lock
At θ = ±90° the first and last rotation axes line up: roll and yaw rotate about the same physical axis. Only their difference (θ = +90°) or sum (θ = −90°) is defined: