function polygonArea(points) { var i, j; var area = 0; for (i = 0; i < points.length; i++) { j = (i + 1) % points.length; area += points[i].x * points[j].y; area -= points[i].y * points[j].x; } area /= 2; return Math.abs(area); }
原文地址:http://blog.csdn.net/jcx5083761/article/details/43935947