Skip to content

Instantly share code, notes, and snippets.

View anestin's full-sized avatar

anestin

View GitHub Profile
var polygon={
area: function(points){
var sum=0, n=points.length;
if(points[0][0] != points[n-1][0] || points[0][1] != points[n-1][1]){
sum += (points[n-1][0]*points[0][1] - points[0][0]*points[n-1][1]);
}
for(var i=0; i < n-1; ++i){
sum += (points[i][0]*points[i+1][1] - points[i+1][0]*points[i][1]);