如何创建没有自交点的平行折线?
创建与现有折线平行的折线的简单算法很简单:您可以计算每个顶点的法线(作为线段法线的平均值),并使用法线以所需的任意数量置换顶点。
然而,当我尝试在弯曲的折线上使用此算法时,存在一个图形问题,即形成弧的一系列点。当我创建与圆弧折线平行的线时,一切都很好,直到我增加足够的距离,使投影顶点通过其法线创建一条折线,其中从一个顶点前进到另一个顶点实际上沿相反方向移动,从而创建自相交。
如何有效地从平行折线中删除这些顶点?我虽然比较了线段的方向:如果生成的线段不平行,则意味着我已经到达平行折线与自身相交的点。然而,这对于小线段(弯曲的折线将生成更小的线段)或最初具有退化顶点(一个顶点等于下一个顶点)的折线来说效果不太好。
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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
平行多段线在图形界中称为偏移多段线。看起来生成偏移折线而没有退化几何工件的方法是使用 直骨架算法。
我还发现了一篇关于该主题的有趣论文,名为 折线曲线的偏移算法。
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.