多边形顶点-顺时针或逆时针 [英] polygon vertices - clockwise or counterclockwise

查看:245
本文介绍了多边形顶点-顺时针或逆时针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我碰到了此链接 http://www.mathopenref.com/coordpolygonarea2.html

它说明了如何计算多边形的面积,并有助于识别输入的多边形顶点是顺时针还是逆时针。

It explains how to calculate the area of a polygon and helps to identify whether the polygon vertices we entered is clockwise or counter clockwise.

如果area值为+ ve,则为顺时针;如果为-nv,则为逆时针。

If area value is +ve, it is clockwise, if it is -nv then it is in counterclockwise.

我的要求是仅确定是顺时针还是逆时针。此规则是否正常运行(尽管存在链接中提到的限制)。我只有规则的多边形(不复杂,没有自相交),但顶点更多。

My requirement is to identify only whether it is clockwise or counterclockwise. Is this rule will work correctly (though there are limitations as mentioned in the link). I have only regular polygons (not complicated, no self intersections) but the vertices are more.

我对面积值的准确性不感兴趣,只是想知道环的旋转。

I am not interested in the area value accuracy, just to know the ring rotation.

对此还有其他想法。

推荐答案

对于凸多边形:

Select two edges with a common vertex. 
Lets say, edge1 is between vertex A and B. Edge2 is between vertex B and C.
Define to vectors: vect1: A----->B
                   vect2: B----->C
Cross product vect1 and vect2. 
If the result is positive, the sequence A-->B-->C is Counter-clockwise. 
If the result is negative, the sequence A-->B-->C is clockwise. 

这篇关于多边形顶点-顺时针或逆时针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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