平滑多段线,变形最小 [英] Smooth polyline with minimal deformation

查看:207
本文介绍了平滑多段线,变形最小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个2D闭合多段线,相当平滑。然而,定义多段线的顶点间距并不相同。有时候两个会非常接近,有时多达四个会非常接近。



我想平滑多段线,但是常规平均算法往往会缩小面积:

pre $ for(int i = 0; i <(V.Length-1); i ++)
{
PointF prev = V [i-1]; //我有包装索引的代码。
PointF next = V [i + 1];
PointF pt = V [i];

float ave_x = one_third *(prev.X + next.X + pt.X);
float ave_y = one_third *(prev.Y + next.Y + pt.Y);

smooth_polyline [i] = new PointF(ave_x,ave_y);
}

我的多段线包含数千个点,两个相邻段之间的角度通常较小比1度还要好。



有没有更好的方法来平滑这些曲线,这会使顶点更均匀地分开,而不会影响面积太多? b $ b

解决方案

您可以查看曲线简化文献,例如Douglas-Peucker算法或本文 http://www.cs.ait.ac.th/~guha/papers/simpliPoly.pdf

如果您需要均匀间隔的顶点,即使它们定义的相邻线段几乎是共线的,也可能无法正常工作。


I've got a 2D closed polyline, which is reasonably smooth. The vertices that define the polyline however are not spaced equally. Sometimes two will be very close, sometimes as many as four will be very close together.

I'd like to smooth the polyline, but a regular averaging algorithm tends to shrink the area:

for (int i = 0; i < (V.Length-1); i++)
{
   PointF prev = V[i-1]; //I have code that wraps the index around.
   PointF next = V[i+1];       
   PointF pt = V[i];

   float ave_x = one_third * (prev.X + next.X + pt.X);
   float ave_y = one_third * (prev.Y + next.Y + pt.Y);

   smooth_polyline[i] = new PointF(ave_x, ave_y);
}

My polylines contain thousands of points and the angle between two adjacent segments is typically less than 1 degree.

Is there a better way to smooth these curves, something which will space the vertices more equally, without affecting the area too much?

解决方案

You could look at the "curve simplication" literature such as the Douglas-Peucker algorithm or this paper http://www.cs.ait.ac.th/~guha/papers/simpliPoly.pdf.

This probably won't work well if you need evenly spaced vertices even when the adjacent line segments they define are nearly collinear.

这篇关于平滑多段线,变形最小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆