1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//! Computational geometry algorithms for 2D spatial data.
//!
//! This module provides fundamental geometric algorithms commonly used in
//! spatial computing, robotics, GIS, and scientific computing:
//!
//! - [`convex_hull`] — Andrew's monotone chain, Graham scan, Jarvis march,
//! point-set diameter.
//! - [`polygon`] — Shoelace area, point-in-polygon, centroid, perimeter,
//! [`Polygon`] struct with hole support.
//! - [`closest_pair`] — O(n log n) divide-and-conquer closest pair,
//! pairwise distances, farthest pair.
//! - [`triangulation`] — Ear clipping, fan triangulation, circumcircle,
//! incircle, triangle quality.
//!
//! # Examples
//!
//! ## Convex hull
//!
//! ```
//! use scirs2_spatial::geom::convex_hull_2d;
//!
//! let pts = vec![[0.0_f64,0.0],[1.0,0.0],[1.0,1.0],[0.0,1.0],[0.5,0.5]];
//! let hull = convex_hull_2d(pts);
//! assert_eq!(hull.len(), 4);
//! ```
//!
//! ## Polygon area
//!
//! ```
//! use scirs2_spatial::geom::polygon_area;
//!
//! let sq = [[0.0_f64,0.0],[1.0,0.0],[1.0,1.0],[0.0,1.0]];
//! assert!((polygon_area(&sq) - 1.0).abs() < 1e-12);
//! ```
//!
//! ## Closest pair
//!
//! ```
//! use scirs2_spatial::geom::closest_pair;
//!
//! let pts = [[0.0_f64,0.0],[3.0,4.0],[1.0,1.0]];
//! let (i, j, d) = closest_pair(&pts).unwrap();
//! assert!((d - 2_f64.sqrt()).abs() < 1e-9);
//! ```
//!
//! ## Triangulation
//!
//! ```
//! use scirs2_spatial::geom::ear_clipping;
//!
//! let sq = [[0.0_f64,0.0],[1.0,0.0],[1.0,1.0],[0.0,1.0]];
//! let tris = ear_clipping(&sq);
//! assert_eq!(tris.len(), 2);
//! ```
// ── Re-exports ─────────────────────────────────────────────────────────────────
pub use ;
pub use ;
pub use ;
pub use ;