Minimum oriented bounding box. Implementation in Grasshopper + Python script node

BEST PICK
I think it is important to point out that Mitch’ script (py) gives very good minimal volume results although it’s not the fastest, so depending on requirement (speed or accuracy) you should try out which one of the components gives what you need or want.

For a comparison i made a silly handrail, and converted it into a mesh (for the PlaneFit component, but in this case it didn’t help better the result) and tried all three components.

R6 Enhanced
I also enhanced the parallel version by allowing it to make smaller rotation attempts than whole degrees (1º) by increasing the steps (D) to greater than 180 steps. All rotations over 180 steps reduces the rotation with a factor (180 / rotations) while still covering a full 180º rotation series.
Out of curiosity I also added an input I (Iterations) which causes the internal algorithm to repeat itself I times by starting over with the resulting plane from the previous full round of rotation attempts as the initial starting plane.

Interestingly enough no improvment is gained by performing more iterations though, probably because any repeated rotations will only be identical to the previous ones. Modifying the rotation angle based on the interation value perhaps would make it effective, but I haven’t tried.

What works though is to increase the rotations (D) to a value over 180 (degrees), which will reduce the rotation degree to less than 1º whole degree. The important point is that by manually increasing this value - and carefully watch the resulting min volume - was the only way I could come close to the results produced by Mitch’ MinBB component (and even beat it in some cases). But I bet there are cases where your prio is smallest volume and you wouldn’t want to manually drag the slider until you find the smallest volume. And then Mitch’ component seems to be the best choice.

Anyway, here’s a very fast version (R6) which can compete with Mitch component, but only if you manually drag the D slider (which I did for the below screenshots) until you come close to, or perhaps even beat Mitch: :slight_smile:

Fig 1. I have indicated the fact that incerasing iterations doesn’t improve the final result as “useless”.

The silly handrail in this test with almost identical results for the Parallel version (magneta) and Mitch (cyan):

The point being that sometimes an initial workpiece really needs to be as small as possible, to the extent that millimeters matters.

R6 with the more fine grained rotation steps (< 1º):
minimalboundingbox-py2csharp_R6.gh (703.5 KB)

Next (R7) I may try (if/when I have the time) to automate the gradual adjustment of the rotation degree which was done manually in the example above. Automating this seems to be the only way to beat Mitch in finding the smallest volume. - Applaud to @Helvetosaur (Mitch), everyone!

// Rolf

Edit: Fixed documentation in image and in the component code

5 Likes