source:
node_modules/d3-polygon/src/area.js@
a762898
| Last change on this file since a762898 was e4c61dd, checked in by , 6 months ago | |
|---|---|
|
|
| File size: 243 bytes | |
| Rev | Line | |
|---|---|---|
| [e4c61dd] | 1 | export default function(polygon) { |
| 2 | var i = -1, | |
| 3 | n = polygon.length, | |
| 4 | a, | |
| 5 | b = polygon[n - 1], | |
| 6 | area = 0; | |
| 7 | ||
| 8 | while (++i < n) { | |
| 9 | a = b; | |
| 10 | b = polygon[i]; | |
| 11 | area += a[1] * b[0] - a[0] * b[1]; | |
| 12 | } | |
| 13 | ||
| 14 | return area / 2; | |
| 15 | } |
Note:
See TracBrowser
for help on using the repository browser.
