pg2pl.js
function ccw(c) {
    var n = c.length
    var area = [0]
    for(var j=0; j<n; ++j) {
      var a = positions[c[j]]
      var b = positions[c[(j+1)%n]]
      var t00 = twoProduct(-a[0], a[1])
      var t01 = twoProduct(-a[0], b[1])
      var t10 = twoProduct( b[0], a[1])
      var t11 = twoProduct( b[0], b[1])
      area = robustSum(area, robustSum(robustSum(t00, t01), robustSum(t10, t11)))
    }
    return area[area.length-1] > 0
  }
function ccw(c) {
    var n = c.length
    var area = [0]
    for(var j=0; j<n; ++j) {
      var a = positions[c[j]]
      var b = positions[c[(j+1)%n]]
      var t00 = twoProduct(-a[0], a[1])
      var t01 = twoProduct(-a[0], b[1])
      var t10 = twoProduct( b[0], a[1])
      var t11 = twoProduct( b[0], b[1])
      area = robustSum(area, robustSum(robustSum(t00, t01), robustSum(t10, t11)))
    }
    return area[area.length-1] > 0
  }
function ccw ( c ) { var n = c . length var area = [ 0 ] for ( var j = 0 ; j < n ; ++ j ) { var a = positions [ c [ j ] ] var b = positions [ c [ ( j + 1 ) % n ] ] var t00 = twoProduct ( - a [ 0 ] , a [ 1 ] ) var t01 = twoProduct ( - a [ 0 ] , b [ 1 ] ) var t10 = twoProduct ( b [ 0 ] , a [ 1 ] ) var t11 = twoProduct ( b [ 0 ] , b [ 1 ] ) area = robustSum ( area , robustSum ( robustSum ( t00 , t01 ) , robustSum ( t10 , t11 ) ) ) } return area [ area . length - 1 ] > 0 }
Check orientation of a polygon using exact arithmetic
Check orientation of a polygon using exact arithmetic