aboutsummaryrefslogtreecommitdiff
path: root/src/math/surface.rs
diff options
context:
space:
mode:
authorArne Dußin2020-12-21 21:12:01 +0100
committerGitHub2020-12-21 21:12:01 +0100
commitc435f278eddcada279fdc424120e4a1448843c20 (patch)
treebe9a5601e99608966d4ccd146c3bfb3a70c7fc02 /src/math/surface.rs
parent3bc690803fb59493ea8180fd630d65b3e26642d0 (diff)
parent82d11b7d3e15d8175accf7579db1fbe528fc6583 (diff)
downloadgraf_karto-c435f278eddcada279fdc424120e4a1448843c20.tar.gz
graf_karto-c435f278eddcada279fdc424120e4a1448843c20.zip
Merge pull request #24 from LordSentox/refactor
Refactor to make interaction between tools easier
Diffstat (limited to 'src/math/surface.rs')
-rw-r--r--src/math/surface.rs21
1 files changed, 21 insertions, 0 deletions
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<T: Scalar + Copy> {
+ /// Checks if a point lies on this surface.
+ fn contains_point(&self, point: &Vec2<T>) -> bool;
+
+ /// Checks if a line segment is entirely contained by this surface.
+ fn contains_line_segment(&self, line_segment: &LineSegment<T>) -> bool;
+
+ /// Checks if a rectangle is entirely contained inside this surface.
+ fn contains_rect(&self, rect: &Rect<T>) -> bool;
+
+ /// Checks if a polygon is contained wholly by this surface.
+ fn contains_polygon(&self, polygon: &Polygon<T>) -> 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<T>) -> bool;
+}