Polyline offset algorithm
-
Hello, i have set of 2D points and i want to offset with a given distance (like offset command in AutoCAD) i do not know how to deal with corners. i have searched on Internet, there are advanced methods like straight skeletons etc. but my polyline is not self crossing and no holes in it. Is there any simple method? any references? Best Regards. Bekir
-
Hello, i have set of 2D points and i want to offset with a given distance (like offset command in AutoCAD) i do not know how to deal with corners. i have searched on Internet, there are advanced methods like straight skeletons etc. but my polyline is not self crossing and no holes in it. Is there any simple method? any references? Best Regards. Bekir
Why can't you just iterate through the points and add your offset to each one? It seems like this should translate the corners along with everything else.
-
Why can't you just iterate through the points and add your offset to each one? It seems like this should translate the corners along with everything else.
Just translating the edges with the offset distance will not work. I have found an algorithm not tested throughly, but it is working at least for my very simple 3 points polyline test :) http://objectmix.com/graphics/132987-draw-parallel-polyline-algorithm-needed.html[^] Best Regards. Bekir.
-
Just translating the edges with the offset distance will not work. I have found an algorithm not tested throughly, but it is working at least for my very simple 3 points polyline test :) http://objectmix.com/graphics/132987-draw-parallel-polyline-algorithm-needed.html[^] Best Regards. Bekir.
beko wrote:
Just translating the edges with the offset distance will not work.
Why not?
beko wrote:
I have found an algorithm not tested throughly, but it is working at least for my very simple 3 points polyline test
What kind of test you did? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
beko wrote:
Just translating the edges with the offset distance will not work.
Why not?
beko wrote:
I have found an algorithm not tested throughly, but it is working at least for my very simple 3 points polyline test
What kind of test you did? :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain ClarkeHello, At the end, it is a translation however it must be implemented with respect to the normals, as far as i read through if it is a parametric curve then it is rather complicated. If you like to see how much it can further get complicated, you can have a look at the link below. http://timeguy.com/cradek-files/emc/liu2007_line_arc_offset.pdf[^] for the test, i have just created a polyline with three points and used the algorithm from Eduardo in my earlier reply, and compared it with AutoCAD output :) Best Regards.
-
Hello, At the end, it is a translation however it must be implemented with respect to the normals, as far as i read through if it is a parametric curve then it is rather complicated. If you like to see how much it can further get complicated, you can have a look at the link below. http://timeguy.com/cradek-files/emc/liu2007_line_arc_offset.pdf[^] for the test, i have just created a polyline with three points and used the algorithm from Eduardo in my earlier reply, and compared it with AutoCAD output :) Best Regards.
That paper seems to give a good description of how to do it. It's complicated, you will have lots of cases - you'll just have to get used to it.
Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
-
Hello, i have set of 2D points and i want to offset with a given distance (like offset command in AutoCAD) i do not know how to deal with corners. i have searched on Internet, there are advanced methods like straight skeletons etc. but my polyline is not self crossing and no holes in it. Is there any simple method? any references? Best Regards. Bekir
There is no simple solution to this problem, the best known general solution, is to create capsules between consecutive point pairs of your polyline where the capsule width is the offset, then union the capsule outlines. The capsule may be centered around the edge or it may be biased towards one side of the edge it is really up to the end requirement. For the union operation use something like Alan Murta's Generic Polygon Clipper library. If you know your polyline is enclosed and represents a convex polygon, then simply calculate the centroid, then offset each edge by the product of the desired offset amount and the vector composed of the mid-point of the edge at hand minus the centroid. A simple example can be found here: http://www.codeproject.com/KB/recipes/Wykobi.aspx
-
There is no simple solution to this problem, the best known general solution, is to create capsules between consecutive point pairs of your polyline where the capsule width is the offset, then union the capsule outlines. The capsule may be centered around the edge or it may be biased towards one side of the edge it is really up to the end requirement. For the union operation use something like Alan Murta's Generic Polygon Clipper library. If you know your polyline is enclosed and represents a convex polygon, then simply calculate the centroid, then offset each edge by the product of the desired offset amount and the vector composed of the mid-point of the edge at hand minus the centroid. A simple example can be found here: http://www.codeproject.com/KB/recipes/Wykobi.aspx