I have found this problem in a book and am trying desperately to solve it. The Question itself is: Create a rooftop (non-flat roofs) with the maximum height. The Walls are either in an angle of 90 degrees or parallel.
My approach:
I have all the edge points. So I can use a scanline approach. I will sort all my points on the x-Axis and then y-Axis. I will then go through my whole list of points and draw a line in 45° to the walls. I will check if any line intersects with my current line I've already drawn. If there's no match I will go to the next point and draw another line 45° to the walls. Now the chance is high that the last 2 lines intersect and so I will make a new point at the point of intersection.
The problem I have is that there would be a lot of special cases. Is there an easier method which I did not think about? Are there other algorithms which are more suited for this kind of problem? What would be your idea to this kind of problem?
Example:
This is what imagine the roof to look like.