function polygonLength(vertices){
    var i = -1,
        n = vertices.length,
        b = vertices[n - 1],
        xa,
        ya,
        xb = b[0],
        yb = b[1],
        perimeter = 0;

    while (++i < n) {
      xa = xb;
      ya = yb;
      b = vertices[i];
      xb = b[0];
      yb = b[1];
      xa -= xb;
      ya -= yb;
      perimeter += Math.sqrt(xa * xa + ya * ya);
    }

    return perimeter;
  }
// Calculates the length of a polygon's perimeter. See https://github.com/d3/d3-polygon/blob/master/src/length.js
Calculates the length of a polygon's perimeter.
Calculates the length of a polygon ' s perimeter .
function polygonLength(vertices){
    var i = -1,
        n = vertices.length,
        b = vertices[n - 1],
        xa,
        ya,
        xb = b[0],
        yb = b[1],
        perimeter = 0;
    while (++i < n) {
      xa = xb;
      ya = yb;
      b = vertices[i];
      xb = b[0];
      yb = b[1];
      xa -= xb;
      ya -= yb;
      perimeter += Math.sqrt(xa * xa + ya * ya);
    }
    return perimeter;
  }
function polygonLength ( vertices ) { var i = - 1 , n = vertices . length , b = vertices [ n - 1 ] , xa , ya , xb = b [ 0 ] , yb = b [ 1 ] , perimeter = 0 ; while ( ++ i < n ) { xa = xb ; ya = yb ; b = vertices [ i ] ; xb = b [ 0 ] ; yb = b [ 1 ] ; xa -= xb ; ya -= yb ; perimeter += Math . sqrt ( xa * xa + ya * ya ) ; } return perimeter ; }
Calculates the length of a polygon's perimeter.
Calculates the length of a polygon ' s perimeter .