Skip to content

Commit

Permalink
Merge pull request #26 from pshriwise/fix-bb-init
Browse files Browse the repository at this point in the history
Fix bounding box junk values.
  • Loading branch information
pshriwise authored Oct 7, 2024
2 parents b106936 + 4e67ee4 commit 1a0d5ab
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions include/xdg/bbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace xdg {
union BoundingBox {
struct {
double min_x;
double min_y;
double min_z;
double max_x;
double max_y;
double max_z;
double min_x {0.0};
double min_y {0.0};
double min_z {0.0};
double max_x {0.0};
double max_y {0.0};
double max_z {0.0};
};
double bounds[6];

Expand Down Expand Up @@ -55,9 +55,7 @@ void update(const BoundingBox& other) {
}

Position center() const {
return Position {(min_x + max_x) / 2.0,
(min_y + max_y) / 2.0,
(min_z + max_z) / 2.0};
return Position {(min_x + max_x), (min_y + max_y), (min_z + max_z)} * 0.5;
}

static BoundingBox from_points(const std::vector<Position>& points) {
Expand Down

0 comments on commit 1a0d5ab

Please sign in to comment.