MCPcopy Create free account
hub / github.com/breck7/scroll / length

Function length

external/.d3.js:14419–14441  ·  view source on GitHub ↗
(polygon)

Source from the content-addressed store, hash-verified

14417}
14418
14419function length(polygon) {
14420 var i = -1,
14421 n = polygon.length,
14422 b = polygon[n - 1],
14423 xa,
14424 ya,
14425 xb = b[0],
14426 yb = b[1],
14427 perimeter = 0;
14428
14429 while (++i < n) {
14430 xa = xb;
14431 ya = yb;
14432 b = polygon[i];
14433 xb = b[0];
14434 yb = b[1];
14435 xa -= xb;
14436 ya -= yb;
14437 perimeter += Math.hypot(xa, ya);
14438 }
14439
14440 return perimeter;
14441}
14442
14443var defaultSource = Math.random;
14444

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected