From 9799d3c6a8f0c242668203a1c70d7b6cfed3e855 Mon Sep 17 00:00:00 2001 From: Arne Dußin Date: Tue, 15 Dec 2020 00:46:54 +0100 Subject: Refactor to make interaction between tools easier --- src/math/surface.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/math/surface.rs (limited to 'src/math/surface.rs') diff --git a/src/math/surface.rs b/src/math/surface.rs new file mode 100644 index 0000000..da265d8 --- /dev/null +++ b/src/math/surface.rs @@ -0,0 +1,21 @@ +use super::{LineSegment, Polygon, Rect, Vec2}; +use nalgebra::Scalar; + +/// Trait that describes an area in the vector space on the field of T +pub trait Surface { + /// Checks if a point lies on this surface. + fn contains_point(&self, point: &Vec2) -> bool; + + /// Checks if a line segment is entirely contained by this surface. + fn contains_line_segment(&self, line_segment: &LineSegment) -> bool; + + /// Checks if a rectangle is entirely contained inside this surface. + fn contains_rect(&self, rect: &Rect) -> bool; + + /// Checks if a polygon is contained wholly by this surface. + fn contains_polygon(&self, polygon: &Polygon) -> bool; + + /// Checks if this surface is contained by the rect in it's entirety. Think of it as the reverse + /// operation for contains_... on a rectangle. + fn is_inside_rect(&self, rect: &Rect) -> bool; +} -- cgit v1.2.3-70-g09d2