[Math] Forming a simple polygon from the extrusion of a polygonal chain

algorithmsgeometrygraph theorypolygons

Let's say I have a set of vertices connected by edges to form a polygonal chain. Each vertex may be shared by a number of edges to form various sub-chains. An example is shown below.

Figure 1

Each edge has a value of thickness attached to it. I then extrude the chain along the normal of each edge by an amount determined by the edges's thickness, to form a closed polygon. Extruding around each edge individually leads to overlapping and empty wedges however, as shown below.

Figure 2

I'm looking for a way to create a single, closed simple polygon from this method. Gaps and overlaps can be resolved by finding the intersection points of the formed rectangles, although this doesn't explain how I should actually go about solving the problem in more complicated scenarios. For example, the rectangles formed in the star structure shown have many intersection points with each other. What I'd like is something that looks like this:
Figure 3

Does an algorithm exist to generate such a polygon from a connected set of vertices in this way? If not, what is the best way to approach the problem?

Best Answer

I'm going to partially answer this myself since I found a method that works for an unbranched line segment, however I'm still not sure how to go about a branched line segment as in my original question.

  1. Calculate the points of a rectangle around each line segment, with a desired thickness. Figure 1
  2. Draw a tangent from the two longer lines of each rectangle. Find where they intersect the tangent lines of adjacent rectangles. Figure 2
  3. Use these intersection points to form the polygon. Figure 2
Related Question