beevee: aabb: bounded: add centroid method
This commit is contained in:
parent
eddad707eb
commit
a405af8f88
|
@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue