Function geometric_features::related_ellipse::elipse_features
source · pub fn elipse_features(polygon: Polygon<'_>, precision: usize) -> ElipseFeatures
Expand description
Compute the features of the related elipse of a polygon. Usefull to avoid recomputing the related elipse multiple times.
use geometric_features::related_ellipse::{elipse_features, ElipseFeatures};
let polygon = [
(-10.34, -11.32),
( 3.61, 18.34),
( -3.07, -5.34),
( 19.67, 6.5 )
];
let polygon2: 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 features = elipse_features(&polygon, 200);
assert_eq!(features.major_axis, 23.247229367609776);
assert_eq!(features.minor_axis, 18.561527921248285);
assert_eq!(features.orientation, 1.1140533990057633);
assert_eq!(features.center, (3.816556476304908, 2.4698470796765917));
assert_eq!(features.eccentricity, 0.6020738096588001);
assert_eq!(features.eliptic_deviation, 3.1033783265455486);
let features = elipse_features(&polygon2, 200);
assert_eq!(
ElipseFeatures { major_axis: 4.753561242017376, minor_axis: 4.586863912470367, orientation: 3.999506964053637, center: (8.487782302188705, 5.068631718638504), eccentricity: 0.26249954212114796, eliptic_deviation: 0.5379829218188382 },
features
);