Mat
Mat

Reputation: 4501

outline vectorshape algorithm

consider the red line to be given as a sequence of points

enter image description here

I'm looking for an algorithm to create the outlines of the thick black shape (also as a sequence of points) such that they are ordered cleanly. And the outline should also respect a minimum distance to itself.

What algorithm can I use to achieve this?

Upvotes: 4

Views: 831

Answers (1)

daoudc
daoudc

Reputation: 533

You will need two types of offsetting algorithms:

  1. Offset a curve in both directions to produce a track
  2. Offset a closed curve inwards to produce one or more smaller closed polygons.

Let r be the distance to the red line, and b the desired thickness of the wall between the black lines/tracks.

  • Offset the red line by r using algorithm 1. This may produce a track which overlaps itself, i.e. has "blob-like" areas.
  • Offset the red line inwards using algorithm 2. Use binary search to find the distance d at which the shape splits in two or disappears. If d > b, then offset inwards by d - b to produce the second area. Otherwise the algorithm fails.
  • Subtract the second area from the first.

Upvotes: 2

Related Questions