Vector Overlay Algorithm

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

enter image description here

I am looking for an algorithm to create thick black contours (as well as a sequence of points) so that they are ordered cleanly. And the plan must also keep a minimum distance to itself.

What algorithm can I use to achieve this?

+4
source share
1 answer

You will need two types of offset algorithms :

  • Offset curve in both directions to create a track
  • Offset a closed curve inward to create one or more smaller closed polygons.

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

  • Reset the red line to r using algorithm 1. This may cause the track to overlap, i.e. has "blob-like" areas.
  • Offset the red line using algorithm 2. Use the binary search to find the distance d at which the shape is split into two or disappears. If d> b, then an inward shift by d - b to create a second region. Otherwise, the algorithm fails.
  • Subtract the second area from the first.
+2
source

Source: https://habr.com/ru/post/1344520/


All Articles