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); }
时间: 2024-11-03 22:30:36