Ezequile
Ezequile

Reputation: 29

How to find the largest isosceles trapezium with a set center inscribed in a closed polygon?

I need to find the largest (biggest area) isosceles trapezium inscribed inside a polygon, and the trapezium must have a set center.

The polygon is defined by an array of points in 2D. The polygon is closed and it can be convex or concave. By isosceles trapezium I mean this shape.enter image description here

Which is a quadrilateral with two parallel sides and one line of symmetry.

Center can mean many things, for this problem the center is the following enter image description here

That is, the point where perpendicular line at the middle of the base meets the perpedincular line at the middle of the height.

The center of the trapezium must match an arbitrary point of the polygon. So for instance, if the polygon is the following, and the arbitrary point is the black dot:enter image description here

The inscribed trapezium should be something like this:enter image description here

My sample trapezium is probably not the largest one but lets assume it is. The parallel lines must be horizontal, so the following example is not valid:

enter image description here

I tried reading the algorithms to find out the biggest rectangle inscribed in a polygon, and adapting them, but they don't seem to be very flexible.

Upvotes: 1

Views: 107

Answers (1)

Matt Timmermans
Matt Timmermans

Reputation: 59174

This problem gets a lot easier if you:

  1. Rotate it by 90 degrees; and
  2. Fold it in half

So that this:

Original

Becomes this:

enter image description here

Now, you're only concerned with the maximum height available at every x position, and you only have to find the top line of the best half-trapezoid that fits underneath that envelop:

enter image description here

The envelope is easy to calculate as a piecewise function just by finding the original line segment with the minimum height at every x position.

To find the top line of the best trapezoid, you can try every pair of segments between each pair of zero crossings, and find the best top line that connects those spans.

Upvotes: 1

Related Questions