You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
243 B
16 lines
243 B
5 years ago
|
export default function(polygon) {
|
||
|
var i = -1,
|
||
|
n = polygon.length,
|
||
|
a,
|
||
|
b = polygon[n - 1],
|
||
|
area = 0;
|
||
|
|
||
|
while (++i < n) {
|
||
|
a = b;
|
||
|
b = polygon[i];
|
||
|
area += a[1] * b[0] - a[0] * b[1];
|
||
|
}
|
||
|
|
||
|
return area / 2;
|
||
|
}
|