I'm looking for a method for finding an axis-aligned rectangle inside a concave or convex polygon.
I've been looking around the web, the closest solutions I could find would only fit a convex polygon, and not a concave one. For example -
Finding an axis-aligned rectangle inside a polygon
To be honest I'm not a great math wiz, so I would rather find code samples or a code library, but I guess I could handle some math by myself, or find someone to help me with it.
It would be really nice if the solution could be in Java too, but maybe I'm too greedy :P
Edit: In response to Russell's comment, I'm adding a bit more information.
The bounded rectangle should be as large as possible. The rectangle is intended to contain text inside it. 1 to 4 words max, with support for text wrapping. So if for example it would be too thin, I would place the text vertically instead of horizontally. So for aspect ratio, I guess it needs to be enough for containing 1-4 words either vertically or horizontally with word wrapping. I can resize the text if the rectangle is small, but preferably the text should be as large as possible.
Another requirement that would be nice to have would be that if the general orientation of the polygon is diagonal and the text would fit much better when it's oriented diagonally, then the rectangle wouldn't necessarily be aligned with the axis' but instead be aligned with the diagonal lines of the polygon. I guess this demand is making this really tricky, but if you guys think its possible then it would be great!
I think I've covered all of the requirements now. :P
Thanks!