aboutsummaryrefslogtreecommitdiff
path: root/src/core/bound.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/bound.rs')
-rw-r--r--src/core/bound.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/core/bound.rs b/src/core/bound.rs
index a1c1070..404424e 100644
--- a/src/core/bound.rs
+++ b/src/core/bound.rs
@@ -45,6 +45,15 @@ impl<T: Number> Bound2<T> {
)
}
+ /// Finds the intersected area between two bounds
+ pub fn intersect(&self, b: &Bound2<T>) -> Bound2<T> {
+ Bound2::new(
+ &Vector2::new_xy(max(self.min.x, b.min.x), max(self.min.y, b.min.y)),
+ &Vector2::new_xy(min(self.max.x, b.max.x), min(self.max.y, b.max.y)),
+ )
+ }
+
+
/// Calculates the diagonal vector
///
/// Can be used to calculate the size of the bound
@@ -96,14 +105,6 @@ impl From<&Bound2f> for Bound2i {
}
}
-/// Finds the intersected area between two bounds
-pub fn intersect<T: Number>(a: &Bound2<T>, b: &Bound2<T>) -> Bound2<T> {
- Bound2::new(
- &Vector2::new_xy(max(a.min.x, b.min.x), max(a.min.y, b.min.y)),
- &Vector2::new_xy(min(a.max.x, b.max.x), min(a.max.y, b.max.y)),
- )
-}
-
#[cfg(test)]
mod tests {
use super::*;