outline vectorshape algorithm
consider the red 开发者_如何学编程line to be given as a sequence of points
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?
You will need two types of offsetting algorithms:
- Offset a curve in both directions to produce a track
- 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.
精彩评论