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:
- Convert to depressed cubic via substitution
- Compute discriminant
- For (three real roots): use trigonometric form
- For (one real root): use Cardano's formula with cube roots
Returns 1 or 3 real roots.
Quartic
Solved via the companion matrix approach:
- Normalize to monic form: divide by
- Construct the companion matrix
- Compute eigenvalues using Schur decomposition (via nalgebra)
- Extract real eigenvalues: those with
Returns 0 to 4 real roots.
Usage in Minimal Solvers
| Solver | Polynomial | Degree | Max roots |
|---|---|---|---|
| P3P (Kneip) | Distance ratio | Quartic | 4 |
| 7-point fundamental | Cubic | 3 | |
| 5-point essential | Action matrix eigenvalues | Degree 10 | 10 |
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