diff options
| author | Arne Dußin | 2020-11-21 20:55:47 +0100 |
|---|---|---|
| committer | Arne Dußin | 2020-11-21 20:55:47 +0100 |
| commit | abf55d8d46fc7d5cfccc9f778da6fca10b33d0cd (patch) | |
| tree | e2f849338a1ce9dfff44082fa7d6b8510385f6f9 /src/math/mod.rs | |
| parent | 58ca374fab6dd90c4d7415bdcc98add002274894 (diff) | |
| download | graf_karto-abf55d8d46fc7d5cfccc9f778da6fca10b33d0cd.tar.gz graf_karto-abf55d8d46fc7d5cfccc9f778da6fca10b33d0cd.zip | |
Move containment of points/ lines into trait
Diffstat (limited to 'src/math/mod.rs')
| -rw-r--r-- | src/math/mod.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/math/mod.rs b/src/math/mod.rs index e72a7a4..6f83c98 100644 --- a/src/math/mod.rs +++ b/src/math/mod.rs @@ -10,8 +10,18 @@ pub use self::rect::*; pub use self::triangle::*; pub use self::vec2::*; +use nalgebra::Scalar; use std::cmp::Ordering; +/// 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; +} + /// Round a floating point number to the nearest step given by the step argument. For instance, if /// the step is 0.5, then all numbers from 0.0 to 0.24999... will be 0., while all numbers from /// 0.25 to 0.74999... will be 0.5 and so on. |
