views:

60

answers:

1

Is there a well know algorithm for calculating "parallel graph"? where by parallel graph I mean the same as parallel curve, vaguely called "offset curve", but with a graph instead of a curve. In the best case, it would allow for variable distance for each segment (connection).

Given following picture, where coordinates of nodes connected with red segments are known, as well as desired distance (thickness)

offset graph

how can I calculate points of black outlined polygons?

+2  A: 

Check out the Straight Seleton strategy. There is an example implementation, here. The algorithm's complexity is documented here.

In addition, some other methods are documented here, A Survey of Polygon Offsetting Strategies.

There is a topic at GameDev as well.

Edit: The CGAL also has an implementation on this since v3.3, see the API. The author has nice presented a test file. (Not an implementation.) You can check out the source, however.

Xavier Ho
As a footnote, the most straight-forward way is to solve the line equation give two distances; you will have to pick one solution out of potentially a set of 4 solutions, by checking the point lies on what side of the lines.
Xavier Ho