1
$\begingroup$

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.

  • 0
    @Day, from your description, I afraid that your house roof is highly unconventional. So, sorry, no.2011-01-05

3 Answers 3

2

Try computing the straight skeleton of the polygon. See also http://www.sable.mcgill.ca/~dbelan2/roofs/roofs.html and http://www.vterrain.org/Culture/BldCity/Roof/ for instance.

3

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

  • 1
    @Graviton: The algorithm is described in _[Discrete and Computational Geometry](http://cs.smith.edu/~orourke/DCG/)_, Chapter 5.2011-11-22
2

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.