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 a bug of computing oriented bounding box in tensor #6069

Merged
merged 1 commit into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cpp/open3d/t/geometry/BoundingVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ core::Tensor OrientedBoundingBox::GetMaxBound() const {
core::Tensor OrientedBoundingBox::GetBoxPoints() const {
const t::geometry::AxisAlignedBoundingBox aabb(GetExtent() * -0.5,
GetExtent() * 0.5);
return aabb.GetBoxPoints().Matmul(GetRotation()).Add(GetCenter());
return aabb.GetBoxPoints().Matmul(GetRotation().T()).Add(GetCenter());
}

OrientedBoundingBox &OrientedBoundingBox::Translate(
Expand Down
20 changes: 10 additions & 10 deletions cpp/tests/t/geometry/OrientedBoundingBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,23 +226,23 @@ TEST_P(OrientedBoundingBoxPermuteDevices, Scale) {
TEST_P(OrientedBoundingBoxPermuteDevices, GetBoxPoints) {
core::Device device = GetParam();

core::Tensor center = core::Tensor::Init<float>({-1, -1, -1}, device);
core::Tensor extent = core::Tensor::Init<float>({1.0, 1.0, 1.0}, device);
core::Tensor center = core::Tensor::Init<float>({-1., -1., -1.}, device);
core::Tensor extent = core::Tensor::Init<float>({0.0, 0.0, 1.0}, device);
core::Tensor rotation = core::Tensor::Eye(3, core::Float32, device);

t::geometry::OrientedBoundingBox obb(center, rotation, extent);

auto box_points = obb.GetBoxPoints();

EXPECT_TRUE(
box_points.AllClose(core::Tensor::Init<float>({{-1.5, -1.5, -1.5},
{-0.5, -1.5, -1.5},
{-1.5, -0.5, -1.5},
{-1.5, -1.5, -0.5},
{-0.5, -0.5, -0.5},
{-1.5, -0.5, -0.5},
{-0.5, -1.5, -0.5},
{-0.5, -0.5, -1.5}},
box_points.AllClose(core::Tensor::Init<float>({{-1.0, -1.0, -1.5},
{-1.0, -1.0, -1.5},
{-1.0, -1.0, -1.5},
{-1.0, -1.0, -0.5},
{-1.0, -1.0, -0.5},
{-1.0, -1.0, -0.5},
{-1.0, -1.0, -0.5},
{-1.0, -1.0, -1.5}},
device)));
}

Expand Down