Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a polygon around a polyline like a buffer

I have looked around to find an example of how to take a polyline and create a buffer around it so I end up with a polygon.

So far I found out I need Minkowskis Sums to do so, but I can't get my head around to raw algorithm and translate that in to code.

I would prefer an example in C# or a walkthrough of the algorithm.

like image 904
eNepper Avatar asked Feb 22 '23 08:02

eNepper


1 Answers

You could use the OffsetPolygons() function in the Clipper library, but first you'd need to convert the polyline into a polygon. Do this by appending to the polyline a reverse copy of the polyline. But since duplicate vertices aren't allowed the reverse copy must exclude the first and last vertices: v1,v2,...,vn, v(n-1),...,v2.

enter image description here

like image 171
Angus Johnson Avatar answered Mar 04 '23 08:03

Angus Johnson