Algorithm Search⌘K

Problemcore

Wahba's problem

Also called optimal attitude from vector observations.

Find the rotation that best maps a set of reference unit vectors to their measured body frame directions in weighted least squares.

Wahba's problem asks for the rotation that best explains a set of direction measurements. A spacecraft or a robot knows some directions in a reference frame, for example the direction to the Sun and the local magnetic field from a model, and it measures the same directions in its own body frame. The rotation from the reference frame to the body frame is its attitude. With noise, no rotation matches all pairs, so Wahba (1965) asked for the rotation with the least weighted sum of squared errors. The problem has an exact solution as an eigenvector of a 4×44 \times 4 matrix (Davenport's q-method) or from a singular value decomposition, and a fast iterative one (QUEST). The rotation step of optimal superposition in structural biology is the same problem with vectors that are not unit: the Kabsch algorithm and quaternion superposition solve it there, and this page links them rather than repeating them.

In plain words

You stand in a field at night and see two known stars. You know where those stars are on a sky map, and you see where they are relative to your own head. From this you can work out which way you are facing. With perfect eyes, two stars are enough and the answer is exact. Real sensors are noisy, so the directions you see do not fit any single way of facing. Wahba's problem asks for the way of facing that fits all the seen directions best, with more trust given to the better sensors. "Best" means that the sum of the squared misses is as small as possible. The problem looks hard because a rotation is a constrained object, but it has a clean exact answer.

Definition

Data. Unit vectors r1,…,rnr_1, \ldots, r_n in the reference frame, unit vectors b1,…,bnb_1, \ldots, b_n in the body frame, and weights ai>0a_i > 0. The model is bi=Ari+noiseb_i = A r_i + \text{noise}, where the attitude matrix AA is in the special orthogonal group SO(3)SO(3). In the notation of rigid-body motion, A=Rbs=RsbTA = R_{bs} = R_{sb}^T.

Task. Find

A⋆=arg⁡min⁡A∈SO(3)L(A),L(A)=12∑i=1nai ∣bi−Ari∣2.A^\star = \arg\min_{A \in SO(3)} L(A), \qquad L(A) = \tfrac{1}{2} \sum_{i=1}^n a_i \, |b_i - A r_i|^2 .

The gain form. For unit vectors, ∣bi−Ari∣2=2−2biTAri|b_i - A r_i|^2 = 2 - 2 b_i^T A r_i. With λ0=∑iai\lambda_0 = \sum_i a_i and the attitude profile matrix B=∑iaibiriTB = \sum_i a_i b_i r_i^T,

L(A)=λ0−tr⁡(ABT),L(A) = \lambda_0 - \operatorname{tr}(A B^T),

so the problem is to maximize the linear function tr⁡(ABT)\operatorname{tr}(A B^T) over SO(3)SO(3). All the data enter through the 3×33 \times 3 matrix BB. This identity holds exactly; it is the first step of every known solution.

Constraint. AA must be a rotation, not only an orthogonal matrix. Without the condition det⁡A=1\det A = 1, the answer can be a reflection, which no rigid body can perform.

Variants

  • Two vectors, one exact. The TRIAD method uses exactly two pairs and matches the first one exactly. It does not minimize LL.
  • Non-unit vectors. If the bib_i and rir_i have any lengths, the loss is still a constant minus tr⁡(ABT)\operatorname{tr}(A B^T) with the same BB, so every solution below still applies. This is the centered form of optimal superposition.
  • Weights from noise. Shuster and Oh (1981) chose aia_i as the inverse variance of a sensor noise that is small and symmetric about the true direction. Then A⋆A^\star is a maximum likelihood estimate, and the inverse of the Hessian of LL at A⋆A^\star is the covariance of the attitude error.
  • Dynamic. When the body turns between measurements and a gyro is available, the static problem becomes a filtering problem; see attitude estimation.

Examples

Exact data. Let r1=e1r_1 = e_1, r2=e2r_2 = e_2 with a1=a2=1a_1 = a_2 = 1, and let the true RsbR_{sb} be the rotation by 120120 degrees about (1,1,1)/3(1, 1, 1) / \sqrt{3}, the matrix with rows (0,0,1)(0, 0, 1), (1,0,0)(1, 0, 0), (0,1,0)(0, 1, 0). Then A=RsbTA = R_{sb}^T has rows (0,1,0)(0, 1, 0), (0,0,1)(0, 0, 1), (1,0,0)(1, 0, 0), so b1=(0,0,1)b_1 = (0, 0, 1) and b2=(1,0,0)b_2 = (1, 0, 0). Every method recovers this AA, and the minimum loss is 00.

Two noisy vectors. Keep b1=(0,0,1)b_1 = (0, 0, 1) but tilt b2b_2 by 22 degrees toward b1b_1: b2=(cos⁡2∘,0,−sin⁡2∘)=(0.999391,0,−0.034899)b_2 = (\cos 2^\circ, 0, -\sin 2^\circ) = (0.999391, 0, -0.034899). Now the measured angle between the two directions is 8888 degrees, while the reference angle is 9090 degrees, so no rotation fits both. TRIAD with b1b_1 first fits b1b_1 exactly and misses b2b_2 by 22 degrees, at loss 12(2sin⁡1∘)2=6.0917×10−4\tfrac{1}{2} (2 \sin 1^\circ)^2 = 6.0917 \times 10^{-4}. The optimal rotation misses each vector by 11 degree, at loss (2sin⁡0.5∘)2=3.0461×10−4(2 \sin 0.5^\circ)^2 = 3.0461 \times 10^{-4}, half the loss of TRIAD. The q-method page computes this answer step by step.

No unique answer. If all bib_i are parallel, every rotation about that direction fits equally well, and the minimizer is a whole circle of rotations.

Known algorithms

  • TRIAD method. Two pairs only, closed form, O(1)O(1). Exact for noise-free data, not optimal with noise.
  • Davenport's q-method. The optimal attitude is the unit quaternion that is the eigenvector of the largest eigenvalue of a symmetric 4×44 \times 4 matrix KK built from BB. O(n)O(n) to build BB, then one 4×44 \times 4 symmetric eigenproblem.
  • QUEST. Finds the largest eigenvalue of KK by Newton's method on its characteristic polynomial, starting from λ0\lambda_0, and the eigenvector from a closed-form adjugate column. O(n)O(n) plus a few Newton steps.
  • SVD method. With the singular value decomposition B=USVTB = U S V^T, the optimum is A⋆=Udiag⁡(1,1,det⁡Udet⁡V)VTA^\star = U \operatorname{diag}(1, 1, \det U \det V) V^T (Markley, 1988). The Kabsch algorithm is the same formula for point sets.
  • Faster closed forms. FOAM and ESOQ avoid the eigensolver with other closed forms; Markley and Mortari (2000) compare them with QUEST for speed and robustness.
AlgorithmTimeSpacePropertiesCode
Davenport's q-methodO(n) worstO(1) extradeterministicexactofflineiterative1 language
QUEST algorithmO(n + k) worstO(1) extradeterministicexactofflineiterative1 language
TRIAD methodO(1) worstO(1) extradeterministicnot exactofflineiterative1 language

Bounds

  • Exact recovery (theorem). If the data are exact, bi=A0rib_i = A_0 r_i, and at least two rir_i are not parallel, then A⋆=A0A^\star = A_0 is the unique minimizer and L(A⋆)=0L(A^\star) = 0. Proof: L≥0L \ge 0 and L(A0)=0L(A_0) = 0, and a rotation that fixes two independent directions is the identity.
  • Range of the loss (theorem). 0≤L(A⋆)=λ0−λmax⁡≤λ00 \le L(A^\star) = \lambda_0 - \lambda_{\max} \le \lambda_0, where λmax⁡\lambda_{\max} is the largest eigenvalue of KK; see the proof on the q-method page.
  • Uniqueness (theorem). The minimizer is unique if and only if λmax⁡\lambda_{\max} is a simple eigenvalue of KK. If BB has rank at most 11, as when all bib_i are parallel, the minimizer is not unique.
  • Cost. Any algorithm must read all nn pairs, so Ω(n)\Omega(n) time. The q-method, QUEST and the SVD method reach O(n)O(n), because after BB is formed the remaining work is on a matrix of fixed size.

Reductions

  • To a linear objective. Wahba's problem is equivalent to maximizing tr⁡(ABT)\operatorname{tr}(A B^T) over SO(3)SO(3); only BB matters.
  • To a symmetric eigenproblem. With AA written by a unit quaternion qq, tr⁡(ABT)=qTKq\operatorname{tr}(A B^T) = q^T K q, a quadratic form, so the problem becomes the symmetric eigenproblem for the largest eigenvalue of KK. This is the q-method.
  • To an SVD. Maximizing tr⁡(ABT)\operatorname{tr}(A B^T) over rotations is solved by the SVD of BB, with a sign fix that turns a reflection into a rotation.
  • From optimal superposition. After both point sets are centered, the rotation of least RMSD solves Wahba's problem with bib_i and rir_i the centered points and all weights 11. So the algorithms of one field solve the other.

Applications

  • Spacecraft attitude from star trackers, Sun sensors and magnetometers, where Wahba's problem was first posed.
  • The attitude of a drone or a phone from gravity and the magnetic field when it is not accelerating, often as the measurement step inside a filter.
  • Registration of point sets in computer vision and structural biology, by the reduction from superposition.

References

  1. Grace Wahba, A least squares estimate of satellite attitude, SIAM Review 7(3), 1965, page 409, the problem statement (Problem 65-1)
  2. F. Landis Markley and John L. Crassidis, Fundamentals of Spacecraft Attitude Determination and Control, Springer, 2014, Chapter 5 (static attitude determination methods)
  3. F. Landis Markley and Daniele Mortari, Quaternion attitude estimation using vector observations, Journal of the Astronautical Sciences 48(2-3), 2000, pages 359 to 380, the survey of solutions of Wahba's problem: the q-method, QUEST, the SVD method and the faster methods
  4. F. Landis Markley, Attitude determination using vector observations and the singular value decomposition, Journal of the Astronautical Sciences 36(3), 1988, pages 245 to 258, the solution of Wahba's problem from the singular value decomposition of the attitude profile matrix

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a contract.yaml