Generate roof from a 2D polygon

1.3k Views Asked by At

Let's say we have a 2D Polygon ( it can be concaved or convex), and on top of this polygon we are required to build a house roof. What is the algorithm that one can use for this?

The conditions:

  1. The roof cannot be $0^o$ or $90^o$.
  2. The created roof piece must be as smooth as possible ( smooth is defined as first order differentiable), meaning the slope of the roof must not change unnecessarily.

I'm sorry if the conditions sound vague. If you get lost, just think about this: you have a house, how do you generate the roof profile?

Note: The roof plan must be uniformly sloping, so no circle, or bump can be used.

3

There are 3 best solutions below

0
On BEST ANSWER
0
On

Start at the outside. Step inwards a small amount to generate a first level (polygonal) curve at a small height above the wall. Project "ridge" lines from outward corners of house (or crotch lines for inside corners) through corresponding corners of the new polygon (I guess they'll be bisecting the angles of the original polygon) and whenever two or more ridgelines, or two or more of the edges meet, repeat the process starting with the reduced polygon(s) which give the level curve through the point of intersection.

4
On

Here is an image I happen to have prepared for a book. It shows the medial-axis polyhedron over a convex polygon, which coincides with the straight skeleton as in lhf's answer, and also with the offset-procedure in alQpr's answer. Sides slope at $45^\circ$.
MedialAxis Polyhedron