How to get object oriented bounding box of a rotated room

How to get object oriented bounding box of a rotated room

amrut.modani.wwi
Participant Participant
4,262 Views
4 Replies
Message 1 of 5

How to get object oriented bounding box of a rotated room

amrut.modani.wwi
Participant
Participant

The get_BoundingBox returns an axis aligned bounding box. This is good and very quick when my rooms are orthogonal. However, for rooms which are at an angle/rotated in their orientation, how do I get a bounding box which is also rotated (see the image attached).

amrutmodaniwwi_0-1646384891513.png

 

I am trying to create an automation tool to place lighting fixtures based on standard spacing as per our company. For linear lights, I want to rotate them for respective to the rooms which don't have an orthogonal orientation.
Any help on how to achieve this if rotated bounding box is not possible? TIA

 

0 Likes
Accepted solutions (1)
4,263 Views
4 Replies
Replies (4)
Message 2 of 5

jeremy_tammik
Alumni
Alumni
Accepted solution

I would suggest using the convex hull instead of the bounding box. Apparently, judging from your sample images, you just require the 2D bounding box, or the 2D convex hull. It is very easy to calculate:

 

 

If you like, you can them simplify and enlarge the convex hull to any rotated bounding box you prefer.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 3 of 5

jeremy_tammik
Alumni
Alumni

... When you say 'object oriented bounding box' that assumes that your room has a well defined orientation at all. Unfortunately, it does not. You personally can define one, for instance by checking which wall has the greatest length and decreeing that to be the room's X axis. However, that would be your personal opinion and nothing canonical. 

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 4 of 5

amrut.modani.wwi
Participant
Participant

Hi Jeremy,

Thanks for the suggestion about convex hull, I have started utilizing it in my code it looks very optimized.


Another suggestion you made is that choosing the longest wall of the room and define it as the room's x axis. This works for simple cases. But many times a wall might be much longer than the room boundary segment as it may be shared by multiple rooms. This may lead to false positives.

Also, if a column comes on a room edge, or the bounding wall has a intersection with another wall outside the room, the edge kind of breaks in multiple boundary segments. So it becomes difficult to know which edge of the room is actually the longest. That is why I was thinking in terms of the rotated bounding box which aligns to the room.

I think I have to play with geometrical concepts for convex hull's vertices and figure out a way to find the longest room edge. I'll post here If I find some solution. Thank for your help.

 

0 Likes
Message 5 of 5

jeremy_tammik
Alumni
Alumni

You say again:

 

That is why I was thinking in terms of the rotated bounding box which aligns to the room.

  

I repeat: there is no such thing, for the very reasons that you list.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes