Bounding box corner question
See original GitHub issueHi Mike,
I came across your Trimesh library for Python after trialling several other tools for generating signed distance functions from STL files. I’ve found yours to be by far the best for what I need, but I have a simple question that I couldn’t quite figure out from looking at the source:
Essentially what I want to do is to fill the bounding box with a 3D rectangular grid of points, and compute the SDF from these. I am able to generate points and calculate the SDF with no problems, but I don’t know how to get the coordinates of the corners of the bounding box. If I use:
box = mesh.bounding_box_oriented.primitive.extents
I get the half-lengths of each side of the bounding box, but if I use these to plot the 8 corners they form a box the same size and shape as the bounding box, but seemingly randomly oriented in space. How can I correctly get the coordinates of the corners so I can construct my meshgrid within the bounding box?
I see that in bounds.py
there is a function corners
that seems to do what I want, but I don’t know where to get the bounds
argument from.
Thank you for your time, Joel
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
Hey, I think you may want to use
mesh.bounding_box
which is the axis aligned bounding box rather thanmesh.bounding_box_oriented
which is the oriented bounding box. Although in order to get the 8 corners of the OBB you could do:trimesh.bounds.corners(m.bounding_box_oriented.bounds)
The mesh.bounds property is computed and always axis- aligned, where the .primitive.extents is pre-transform (by .primitive.transform)
One thing you might consider, is that the oriented bounding box you’re using will probably have a lot less volume. You could generate the grid (axis aligned) the size of the OBB extents, and then transform the grid of query points using the OBB’s transform.
Some ipython noodling:
m.bounding_box_oriented.vertices
works correctly, thank you !