views:

137

answers:

1

The simple algorithm to create a parallel polyline to an existing polyline is simple: you can calculate the normal of each vertex (as the average of the segment's normals) and displace the vertices using the normal with whatever amount you want.

However, there's a graphical problem when I try to use this algorithm on a curved polyline, this is, a succession of points which form an arc. When I create the parallel to the arc polyline, everything is fine until I increase the distance enough that projected vertices through their normals create a polyline where advancing from one vertex to another one actually moves in the reverse direction creating a self-intersection.

How can I remove such vertices from the parallel polyline efficiently? I've though of comparing the direction of the segments: if the generated segments are not parallel, it means I've reached a point were the parallel polyline intersects itself. However, this doesn't work very well for small segments (a curved polyline will generate even smaller segments) or polylines which originally have degenerate vertices (one vertex equal to the next one).

A: 

A parallel polyline is known in the graphic circles as offset polyline. Looks like a method to generate offset polylines without degenerate geometry artifacts are to use Straight Skeleton algorithms.

I've also found an interesting paper on the subject called An offset algorithm for polyline curves.

Grzegorz Adam Hankiewicz