跟踪的形状为最大n边的多边形 [英] Trace a shape into a polygon of max n sides

查看:127
本文介绍了跟踪的形状为最大n边的多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找一种算法,会发现一个不规则的形状,也许不是太不规则,像一个压扁的圆形,在表面上,并跟踪最多n条边的周围形状的多边形。在'n'个maximimum可以基于形状的面积。

I'm looking for an algorithm that will find an irregular shape, maybe not too irregular, like a squashed circle, on a surface, and trace a polygon of a maximum of n sides around the shape. The 'n' maximimum might be based on the area of the shape.

推荐答案

我会做这样的:

  1. 计算切线角度 ANG 及其变化所有曲线段

  1. compute tangent angles ang and its change dang for all curve segments

  • 您可以使用 atanxy 或ATAN2为
  • ANG [I] = atanxy(X [I] -x [I-1],Y [I] -y [I-1]);
  • 宕[I] =昂[I] -Ang [I-1];
  • you can use atanxy or atan2 for that
  • ang[i] = atanxy(x[i]-x[i-1],y[i]-y[i-1]);
  • dang[i] = ang[i]-ang[i-1];

找到inflex点(黑)

  • 在这些点宕的符号改变
  • 宕[I-1] *宕[I + 1]; 0.0
  • 螺母需要妥善处理党= 0.0元(需前后它们扫描)
  • 在这些点将会为你输出面的基本骨架
  • at these points the sign of dang is changing
  • so dang[i-1]*dang[i+1]<0.0
  • nut you need to handle the dang=0.0 elements properly (need to scan before and after them)
  • these points will be the fundamental skeleton for your output polygon

添加颠簸最高点(绿色)

  • 在这些点的切线的角度是最接近inflex点之间
  • 所以要找到两个inflex点 I0 I1
  • 之间的最大点
  • 找到最接近的角度 angavg = 0.5 *(ANG [I0] +昂[I1])
  • 请不要忘记, |昂[I] -angavg |&LT; = PI 所以+/- 2.0 * PI如果这是不正确
  • at these points the tangent angle is between nearest inflex points
  • so to find max point between two inflex points i0 and i1
  • find the closest angle to angavg=0.5*(ang[i0]+ang[i1])
  • do not forget that |ang[i]-angavg|<=PI so +/- 2.0*PI if this is not true

现在你应该拥有所有显著点的封闭多重曲线的...

  • 在它应该是这样的:
  • 在CW / CCW或红/蓝刚刚重新presents的标志宕[I] ...

[注意事项]

  • 输出点类型应该是preserved(inflex / maxpoint)
  • ,因为它可在以​​后用于比较的形状和检测...

这篇关于跟踪的形状为最大n边的多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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