The method of calculating polygon area

Source: Internet
Author: User

Learn the high number of students, will learn the outer product of the vector, but also know that it has a use, you can find triangular area.

• Geometrical meaning of the outer product: The parallelogram area of α and β spanned

• By the method of Triangle area can be generalized to the convex polygon area, from a fixed point, to the other points of the auxiliary line, so it is divided into a number of triangles, the use of the formula to find the area of each triangle can be added. Code implementation: But this method has limitations, only to find the area of convex polygons, for concave polygon seems to be no. Here again to provide a concave and convex are suitable for the method, but I also do not understand, if the great God saw, I would like to enlighten, now thanked. double Area (int n)//Calculate polygon size, bump polygon can be {int i; double s; s = p[0].y * (p[n-1].x-p[1].x); for (i=1; i<n) ;                                     i++) S+=p[i].y * (p[i-1].x-p[(i+1)%n].x) if (s<0) s=s* (-1.0); return 1.0*S/2; • Come here, this is the first time to write this, if there is a mistake please understand, give the proposal.

The method of calculating polygon area

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.