Skip to content

Commit 22e5288

Browse files
Merge pull request #1140 from Geode-solutions/fix/bbox-ellipse
fix(Ellipse): add BoundingBox computation
2 parents 95b3d67 + 8de1b65 commit 22e5288

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

include/geode/geometry/basic_objects/ellipse.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828

2929
namespace geode
3030
{
31+
FORWARD_DECLARATION_DIMENSION_CLASS( BoundingBox );
32+
FORWARD_DECLARATION_DIMENSION_CLASS( Frame );
3133
FORWARD_DECLARATION_DIMENSION_CLASS( OwnerEllipse );
3234
FORWARD_DECLARATION_DIMENSION_CLASS( Point );
33-
FORWARD_DECLARATION_DIMENSION_CLASS( Frame );
3435

3536
template < index_t dimension >
3637
using RefPoint = std::reference_wrapper< const Point< dimension > >;
@@ -60,6 +61,7 @@ namespace geode
6061

6162
[[nodiscard]] const Point< dimension >& center() const;
6263
[[nodiscard]] const Frame< dimension >& axes() const;
64+
[[nodiscard]] BoundingBox< dimension > bounding_box() const;
6365

6466
private:
6567
PointType center_;

src/geode/geometry/basic_objects/ellipse.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ namespace geode
6363
return axes_;
6464
}
6565

66+
template < typename PointType, typename FrameType, index_t dimension >
67+
BoundingBox< dimension >
68+
GenericEllipse< PointType, FrameType, dimension >::bounding_box() const
69+
{
70+
BoundingBox< dimension > bbox;
71+
const Point< dimension >& point = center_;
72+
const Frame< dimension >& axes = axes_;
73+
for( const auto d : LRange{ dimension } )
74+
{
75+
const auto& axe = axes.direction( d );
76+
bbox.add_point( point + axe );
77+
bbox.add_point( point - axe );
78+
}
79+
return bbox;
80+
}
81+
6682
template < index_t dimension >
6783
OwnerEllipse< dimension >::OwnerEllipse(
6884
Point< dimension > center, Frame< dimension > axes )

0 commit comments

Comments
 (0)