index.js
function windingOfRing(ring){
  // 'ring' is an array of [x,y] pairs with the last equal to the first
  // Compute the winding number based on the vertex with the smallest x-value, it precessor and successor. An extremal vertex of a simple, non-self-intersecting ring is always convex, so the only reason it is not is because the winding number we use to compute it is wrong
  var leftVtx = 0;
  for (var i = 0; i < ring.length-1; i++) { if (ring[i][0] < ring[leftVtx][0]) leftVtx = i; }
  if (isConvex([ring[(leftVtx-1).modulo(ring.length-1)],ring[leftVtx],ring[(leftVtx+1).modulo(ring.length-1)]],true)) {
    var winding = 1;
  } else {
    var winding = -1;
  }
  return winding
}
function windingOfRing(ring){
  // 'ring' is an array of [x,y] pairs with the last equal to the first
  // Compute the winding number based on the vertex with the smallest x-value, it precessor and successor. An extremal vertex of a simple, non-self-intersecting ring is always convex, so the only reason it is not is because the winding number we use to compute it is wrong
  var leftVtx = 0;
  for (var i = 0; i < ring.length-1; i++) { if (ring[i][0] < ring[leftVtx][0]) leftVtx = i; }
  if (isConvex([ring[(leftVtx-1).modulo(ring.length-1)],ring[leftVtx],ring[(leftVtx+1).modulo(ring.length-1)]],true)) {
    var winding = 1;
  } else {
    var winding = -1;
  }
  return winding
}
function windingOfRing ( ring ) { // 'ring' is an array of [x,y] pairs with the last equal to the first // Compute the winding number based on the vertex with the smallest x-value, it precessor and successor. An extremal vertex of a simple, non-self-intersecting ring is always convex, so the only reason it is not is because the winding number we use to compute it is wrong var leftVtx = 0 ; for ( var i = 0 ; i < ring . length - 1 ; i ++ ) { if ( ring [ i ] [ 0 ] < ring [ leftVtx ] [ 0 ] ) leftVtx = i ; } if ( isConvex ( [ ring [ ( leftVtx - 1 ) . modulo ( ring . length - 1 ) ] , ring [ leftVtx ] , ring [ ( leftVtx + 1 ) . modulo ( ring . length - 1 ) ] ] , true ) ) { var winding = 1 ; } else { var winding = - 1 ; } return winding }
Function to compute winding of simple, non-self-intersecting ring
Function to compute winding of simple non - self - intersecting ring