pub fn fit_ellipse(polygon: Polygon<'_>) -> (f64, f64, f64, Point)
Expand description

Fit an elipse to a polygon using a scanline algorythe and the “Numerically stable direct least squares fitting of ellipses” algorythm by Halir and Flusser

Example

use geometric_features::related_ellipse::fit_ellipse;
let polygon: Vec<(f64,f64)> = vec![
    ( 8.04,  2.68),
    ( 5.4,   4.4 ),
    ( 6.1,   6.5 ),
    ( 9.24,  6.22),
    (12.12,  5.26),
    ( 9.86,  4.38),
    ( 10.0,  2.42),
    ( 8.86,  4.14)
];
let res = fit_ellipse(&polygon);
assert_eq!(res, (2.376780621008688, 2.2934319562351835, 3.999506964053637, (8.487782302188705, 5.068631718638504)));