Polygon goes backward, counterclockwise, area, and vertex concave and convex

Source: Internet
Author: User

Easy to view and reprint

1. How to determine whether a polygon is clockwise or counterclockwise
For a convex polygon, you only need to calculate a certain point.
Cross Product = (Xi-XI-1), (Yi-Yi-1) x (XI + 1-xi), (yi + 1-yi ))
= (Xi-XI-1) * (yi + 1-yi)-(Yi-Yi-1) * (XI + 1-xi)

If the value of the preceding formula is positive, it is counter-clockwise. If it is negative, it is clockwise.

For a general simple polygon, the above value needs to be calculated for each vertex of the polyon. If there are many positive values, the value is counter-clockwise. If there are many negative values, the value is clockwise.

2. Polygon Area


If the points of a polygon are in a counterclockwise order, the area value is positive, otherwise it is negative.
3. vertex concave and convex
The determination method of vertex concave and convex is introduced. For the area of a triangle consisting of I, I-1, I, I + 1 to be tested, the clockwise characteristics of the triangle are derived, convex vertex. Otherwise, it is a concave vertex)

This article from csdn blog: http://blog.csdn.net/w47189122/archive/2008/03/25/2217383.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.