Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bounding box junk values. #26

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading