Polynomial Solvers

Several minimal geometry solvers in calibration-rs reduce to polynomial equations. This chapter documents the polynomial root-finding utilities used by P3P, 7-point fundamental, and 5-point essential solvers.

Quadratic

Solved via the standard discriminant formula: . Returns 0, 1, or 2 real roots depending on the discriminant sign.

Cubic

Solved using Cardano's formula:

  1. Convert to depressed cubic via substitution
  2. Compute discriminant
  3. For (three real roots): use trigonometric form
  4. For (one real root): use Cardano's formula with cube roots

Returns 1 or 3 real roots.

Quartic

Solved via the companion matrix approach:

  1. Normalize to monic form: divide by
  2. Construct the companion matrix
  3. Compute eigenvalues using Schur decomposition (via nalgebra)
  4. Extract real eigenvalues: those with

Returns 0 to 4 real roots.

Usage in Minimal Solvers

SolverPolynomialDegreeMax roots
P3P (Kneip)Distance ratioQuartic4
7-point fundamentalCubic3
5-point essentialAction matrix eigenvaluesDegree 1010

The 5-point solver uses eigendecomposition of a matrix rather than a polynomial solver directly, but the underlying mathematics involves degree-10 polynomial constraints.

Numerical Considerations

  • All roots are deduplicated (roots closer than are merged)
  • Real root extraction uses a threshold on the imaginary part ()
  • The companion matrix approach is more numerically stable than analytical quartic formulas for extreme coefficient ratios