implement Bounded2d for ConvexPolygon (#18286)

# Objective

- Implement `Bounded2d` for `ConvexPolygon`
This commit is contained in:
Lynn 2025-03-13 17:35:52 +01:00 committed by GitHub
parent 2c22bc12a0
commit f245490e4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,8 +4,9 @@ use crate::{
bounding::BoundingVolume,
ops,
primitives::{
Annulus, Arc2d, Capsule2d, Circle, CircularSector, CircularSegment, Ellipse, Line2d,
Plane2d, Polygon, Polyline2d, Rectangle, RegularPolygon, Rhombus, Segment2d, Triangle2d,
Annulus, Arc2d, Capsule2d, Circle, CircularSector, CircularSegment, ConvexPolygon, Ellipse,
Line2d, Plane2d, Polygon, Polyline2d, Rectangle, RegularPolygon, Rhombus, Segment2d,
Triangle2d,
},
Dir2, Isometry2d, Mat2, Rot2, Vec2,
};
@ -375,6 +376,16 @@ impl<const N: usize> Bounded2d for Polygon<N> {
}
}
impl<const N: usize> Bounded2d for ConvexPolygon<N> {
fn aabb_2d(&self, isometry: impl Into<Isometry2d>) -> Aabb2d {
Aabb2d::from_point_cloud(isometry, self.vertices().as_slice())
}
fn bounding_circle(&self, isometry: impl Into<Isometry2d>) -> BoundingCircle {
BoundingCircle::from_point_cloud(isometry, self.vertices().as_slice())
}
}
#[cfg(feature = "alloc")]
impl Bounded2d for BoxedPolygon {
fn aabb_2d(&self, isometry: impl Into<Isometry2d>) -> Aabb2d {