查找List <point>是表示常规或不规则多边形</point>

时间:2010-08-16 11:51:36

标签: c# geometry

如何实施此方法:

private bool IsRegularPolygon(List<Point> seed)

Point对象有2个维度,带有X和Y坐标。

假设它是常规的,我怎样才能找到一边的长度?

谢谢!

1 个答案:

答案 0 :(得分:0)

回想一下高中几何,并考虑是什么使多边形“正常”。

因为如果这就是我所说的,这不是一个很好的答案,我将切入追逐并指出它是一个多边形,所有内角都相等。

因此,这可以将问题减少到确保列表中三个点之间的每个角度相同。如下所示:

get the first point, and the two after it
find the angle between them, store it somewhere
get the second point, and the two after it
find the angle between them, make sure it's the same
repeat the last two steps for all the points in the list

现在记住,如果它是规则的,所有边都是相同的长度,所以找到边长是一个直接的两点间距离计算。

相关问题