Room angle with bounding box, cuboid

Thanks for the reminder. :slight_smile:

Took a look at yours and the lack of documentation made it hard for me to wrap my head around which direction you took, so I started fresh based on my original idea. Hope you don’t mind.

Instead of using vector rotation I took the angle tangent vector at the midpoint and found the angle with the X axis about the global Z, and then used a modulo function to find how far off 90 degrees each value was. This gave me the ‘set to one quadrant’ in one function (I did wrap it in a Math.Round though).

I then grouped the curves, summed the lengths, and found the longest to get the ‘most common angle’ within the room. Rotating the entire polycurve and use that to set the boundingbox from which you can pull the X and Y dimensions which become the parameter values for length and width is pretty straightforward from there.

The result got every one of your dimensions correctly and a few of my own tests too.

Give it a shot rebuilding and let me know if you have questions and I’ll do my best to get you a response.

5 Likes