Jump to content
Developer Wiki and Function Reference Links ×

Largest rectangle within polygon or polyline


rosti

Recommended Posts

Can an Vectorscript solve this problem? The answer is yes.

If you ask for a Vectorscript function for that: The answer is no.

 

And the task is not really clear. You want to find the widest rectangle with the height x? Or you want the have the rectangle with the largest area? Or the widest Rectangle which height is minimum 20% (or some kind like this) of the width?

 

I think the simplest way would be, to make a grid over your polygon. Then you have rows and columns. With that, you could generate the biggest, the widest and the highest recangle. 

 

Not sure, but I think this could be a possible approach. I would do that with python script. There seems to be solutions available on the net. As example here:

https://gist.github.com/zed/776423

 

This code for that looks quite simple. Maybe that script has to be adjusted. As example store the start endpoint of the rectangle inside the script. At the moment this just returns max area, width and height not the position.

 

Interesting and useful task ...  

 

 

Which rectangle?.png

Link to comment

Thank you for replying,

 

Nice image too. 

I had a look at the python script, and it might take me in between a day or maybe a year to understand. 

I will try, but I don't know when I can react on that. 

I assume there are matrix-steps add by each loop until a border is hit somewhere. 

Is that how  a program like Vectorworks renders the fills of polys on screen? 

 

 

 

As a routine for a task like this could serve many cases, I tried not to be that clear. 

In my case I was thinking of a way to find the ideal location of a generated text informing about different rooms or spaces.

If you want the text to be as large as possible, in a circle or square you might locate it at its center.

If you think of a L-shaped room or curved space, the ideal location, could be found by the eye, but to calculate it might be harder.  

 

So for instance for the L-shaped room, using the eye, you would opt between 2 rectangles, and pick the largest and maybe rotate the text 90 degrees. 

 

In case of your image you might opt for the red one.  

 

Looking at the image, I would say as next step could be to compare some initial ratio of the text, by knowing its content, and try to fit such a rectangle best.

So:

Say a rectangle like the green one might have the best ratio, then have the actual text object centered at that green rectangles midpoint. 

After that size of the green rectangle and the text block might reduce the font size, to have it fit, or if the font would get to small to read, you have to, still, move it outside the area by using a pointing device of choise.

yo.png.8a11e4a6b530f02bd756b946ced0d5cb.png

Maybe someone might want to place a symbol within the room. Maybe there might be a hole in the room, or worse.

 

design-by-btrdv.png.5957ba808d70c4185544f305f94152fd.png

 

 

 

 

 

Edited by rosti
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...