Object Oriented Bounding Box

Rotate the bounding box according to the Solid Orientation.

For an instance,
The blue line is the bounding box which I got from default node, but I am in need of bounding box which is marked in red color. Additional information the solid is rotated in all 3 Axis.

What do you know about your solids? Are they always a rectangular box? Are they always the same size?

If they are always rectangular boxes, you could extract orientation vectors from two edges (three points). Then you just have to calculate the extents of the box in each axis direction.

If the solids are not rectangular boxes, how do you want the bounding boxes to be oriented?

Hi @karunakaran

I had a look at it and I’m at loss. But I can show what I found so far.

I thought a way to do it would be to make a bounding box oriented according to one of the sides of solid. But this didn’t seem to work. In a code block you can use the function:

BoundingBox.ByGeometryCoordinateSystem(geometry, coordinate_system);

But the bounding box refuses to have any other orientation other than the world axes, regardless of the coordinate system I put in. It seems to be any issue with Dynamo: http://dynamobim.com/forums/topic/bounding-box-by-geometry-coordinate-system-problem/

I couldn’t find if the issue had been closed or not.

Another method would be to reorient the geometry so that it becomes aligned with world coordinate system, create a bounding box and then reorient the bounding box back to the geometry. But I couldn’t find a way to translate or rotate bounding boxes, so this didn’t work neither. The transformation nodes as Translate and Rotate does not work on BoundingBoxes, only Geometry.

If you don’t actually need a BoundingBox, but a PolySurface with the same shape, then the method above would work.

Thomas Holth


If this is still relevant, there is a function in OpenCV called minrect() which can give the rotated rectangle fitted under the given contour.

I tried this by changing the BoundingBox Transform BasisX and BasisY, but they can’t be set via API for some reason, only get.