Created
December 21, 2014 09:25
-
-
Save jamesktan/820a6ee0f05cfda9a09c to your computer and use it in GitHub Desktop.
Calculate Surface Area of Shape
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGPoint points[N]; | |
CGFloat area = 0; | |
for (int i = 0; i < N; i++) { | |
area += (points[i].x * points[(i+1) % N].y - points[(i+1) % N].x * points[i].y)/2.0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment