mod clipper;
mod graph;
mod node;
mod shape;
mod tolerance;
#[cfg(feature = "cartesian")]
pub mod cartesian;
#[cfg(feature = "spherical")]
pub mod spherical;
pub use self::clipper::Operands;
pub use self::shape::Shape;
pub use self::tolerance::{IsClose, Positive, Tolerance};
pub trait Vertex {
type Scalar;
fn distance(&self, rhs: &Self) -> Self::Scalar;
}
pub trait Edge<'a> {
type Vertex: Vertex + IsClose;
fn new(from: &'a Self::Vertex, to: &'a Self::Vertex) -> Self;
fn midpoint(&self) -> Self::Vertex;
fn contains(
&self,
point: &Self::Vertex,
tolerance: &<Self::Vertex as IsClose>::Tolerance,
) -> bool;
fn intersection(
&self,
rhs: &Self,
tolerance: &<Self::Vertex as IsClose>::Tolerance,
) -> Option<Self::Vertex>;
}
pub trait RightHanded {
fn is_clockwise(&self) -> bool;
}
pub trait Geometry: Sized + RightHanded {
type Vertex: Vertex + IsClose;
type Edge<'a>: Edge<'a, Vertex = Self::Vertex>
where
Self: 'a;
fn from_raw(
operands: Operands<Self>,
vertices: Vec<Self::Vertex>,
tolerance: &<Self::Vertex as IsClose>::Tolerance,
) -> Option<Self>;
fn total_vertices(&self) -> usize;
fn edges(&self) -> impl Iterator<Item = Self::Edge<'_>>;
fn reversed(self) -> Self;
fn winding(
&self,
vertex: &Self::Vertex,
tolerance: &<Self::Vertex as IsClose>::Tolerance,
) -> isize;
}