mod circle;
mod cuboid;
mod line1;
mod line2;
mod polygon;
mod rect;
mod triangle;
pub use circle::Circle;
pub use cuboid::Cuboid;
pub use line1::Line1;
pub use line2::Line2;
pub use polygon::Polygon;
pub use rect::Rect;
pub use triangle::{Orientation, Triangle};
pub type Float = f32;
pub const PI: Float = std::f32::consts::PI;
pub use glam::{Mat2, Mat3, Mat4, Quat, Vec2, Vec3, Vec4};
pub trait Shape {
fn center(&self) -> Vec2;
fn bounds(&self) -> Rect;
fn x_range(&self) -> Line1;
fn y_range(&self) -> Line1;
fn contains_point(&self, point: Vec2) -> bool;
}
pub trait Intersect<T, R> {
fn intersects(&self, other: &T) -> bool;
fn intersection(&self, other: &T) -> Option<R>;
}
pub enum PointIntersection {
One(Vec2),
Two(Vec2, Vec2),
}
impl PointIntersection {
pub fn add(self, p: Vec2) -> Self {
match self {
PointIntersection::One(v) => PointIntersection::Two(v, p),
PointIntersection::Two(v1, v2) => PointIntersection::Two(v1, v2),
}
}
}