beevee: aabb: bounded: add centroid method

This commit is contained in:
Bruno BELANYI 2020-03-24 17:52:28 +01:00
parent eddad707eb
commit a405af8f88

View file

@ -9,6 +9,8 @@ pub trait Bounded {
/// ///
/// [`AABB`]: struct.AABB.html /// [`AABB`]: struct.AABB.html
fn aabb(&self) -> AABB; fn aabb(&self) -> AABB;
/// Return the centroid of self.
fn centroid(&self) -> Point;
} }
/// Implementation of [`Bounded`] for [`AABB`] /// Implementation of [`Bounded`] for [`AABB`]
@ -30,6 +32,10 @@ impl Bounded for AABB {
fn aabb(&self) -> AABB { fn aabb(&self) -> AABB {
*self *self
} }
fn centroid(&self) -> Point {
self.centroid()
}
} }
/// Implementation of [`Bounded`] for [`Point`] /// Implementation of [`Bounded`] for [`Point`]
@ -50,4 +56,8 @@ impl Bounded for Point {
fn aabb(&self) -> AABB { fn aabb(&self) -> AABB {
AABB::with_bounds(*self, *self) AABB::with_bounds(*self, *self)
} }
fn centroid(&self) -> Point {
*self
}
} }