Skip to content

feat: Add AxisAlignedBox conversion helpers#667

Merged
ahcorde merged 5 commits intogazebosim:gz-math8from
anshium:gz-math8
Mar 12, 2025
Merged

feat: Add AxisAlignedBox conversion helpers#667
ahcorde merged 5 commits intogazebosim:gz-math8from
anshium:gz-math8

Conversation

@anshium
Copy link
Copy Markdown
Contributor

@anshium anshium commented Mar 8, 2025

Adds helper functions to create AxisAlignedBox from shapes Origin shapes: Box, Sphere, Capsure, Cylinder

🎉 New feature

Closes #666

Summary

Implementation of static helper functions in gz::math::AxisAlignedBoxHelpers to convert shape objects (Box, Sphere, Capsule, Cylinder) into AxisAlignedBox objects.

I have tried to write the functions in more or less the same format as other files. Since, the functions are template functions, I have kept their implementation in gz/math/detail/AxisAlignedBoxHelpers.hh and the declarations in gz/math/AxisAlignedBoxHelpers.hh.

I have also written comments in the same style as other files.

Also, I have added a few tests to check their correctness.

Test it

Testing can be done by creating a new shape:

math::Box<double> box(2.0, 4.0, 6.0);

Then, using the helper function:

math::AxisAlignedBox aabb = math::AxisAlignedBoxHelpers<double>::ConvertToAxisAlignedBox(box);

Then, can call functions like:

aabb.Min()

The output would be: Vector3d(-1.0, -2.0, -3.0)

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)

Doubts

  1. I am not sure if we need an example / tutorial for these helper functions. Kindly let me know if we do, I will add them.

  2. Also, kindly let me know if the python bindings have to be updated and where do I update the documentation.

anshium added 2 commits March 9, 2025 00:59
Adds helper functions to create AxisAlignedBox from shapes
Origin shapes: Box, Sphere, Capsure, Cylinder

Fixes gazebosim#666

Signed-off-by: anshium <anshchablani@gmail.com>
For the files
AxisAlignedBoxHelpers.hh,
AxisAlignedBoxHelpers.cc
and AxisAlignedBoxHelpers.hh in detail/

Signed-off-by: anshium <anshchablani@gmail.com>
Copy link
Copy Markdown
Contributor

@ahcorde ahcorde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution, Do you mind to add the python bindings too ? If you don't have time to do it please open a issue indicating that Python binding are missing for this new feature. Otherwise you can include them in this PR or open a new one.

anshium added 2 commits March 10, 2025 21:57
style: improve comment formatting

Signed-off-by: anshium <anshchablani@gmail.com>
Signed-off-by: anshium <anshchablani@gmail.com>
@anshium
Copy link
Copy Markdown
Contributor Author

anshium commented Mar 10, 2025

Made the said changes. Working on the python bindings now :)

also add tests

Signed-off-by: anshium <anshchablani@gmail.com>
@anshium
Copy link
Copy Markdown
Contributor Author

anshium commented Mar 10, 2025

Added the python bindings, along with tests.

@anshium
Copy link
Copy Markdown
Contributor Author

anshium commented Mar 12, 2025

@ahcorde Hey! Just checking if there's anything else that needs to be updated/changed on this PR. Let me know if anything needs adjusting. Thanks!

@ahcorde ahcorde merged commit fc736b1 into gazebosim:gz-math8 Mar 12, 2025
15 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in Core development Mar 12, 2025
@ahcorde
Copy link
Copy Markdown
Contributor

ahcorde commented Mar 12, 2025

Thank you for your contribution @anshium, looking forward seeing more PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏛️ ionic Gazebo Ionic 🪵 jetty Gazebo Jetty

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Add helper functions to create AxisAlignedBox objects from other shapes

3 participants