# Generate Roof from a 2D Polygon

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.

-
Is the polygon the "floor plan" of the house? – Blue Jan 5 '11 at 4:25
@Day, you can say that – Graviton Jan 5 '11 at 4:29
How about drawing a circle around the polygon, building a hemispherical dome over it, then slicing off the parts of the dome that extend beyond polygon? – Blue Jan 5 '11 at 4:35
@Day, no, that's not what I have in mind :) – Graviton Jan 5 '11 at 5:48
@Ngu: What additional characteristics is the roof to have? Maybe that it's the same height along the perimeter of the polygon? Have you looked at "bump functions"? en.wikipedia.org/wiki/Bump_function – Blue Jan 5 '11 at 7:25

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$.