index.js
function isConvex(pts, righthanded){
  // 'pts' is an [x,y] pair
  // 'righthanded' is a boolean
  if (typeof(righthanded) === 'undefined') righthanded = true;
  if (pts.length != 3) throw new Error("This function requires an array of three points [x,y]");
  var d = (pts[1][0] - pts[0][0]) * (pts[2][1] - pts[0][1]) - (pts[1][1] - pts[0][1]) * (pts[2][0] - pts[0][0]);
  return (d >= 0) == righthanded;
}
function isConvex(pts, righthanded){
  // 'pts' is an [x,y] pair
  // 'righthanded' is a boolean
  if (typeof(righthanded) === 'undefined') righthanded = true;
  if (pts.length != 3) throw new Error("This function requires an array of three points [x,y]");
  var d = (pts[1][0] - pts[0][0]) * (pts[2][1] - pts[0][1]) - (pts[1][1] - pts[0][1]) * (pts[2][0] - pts[0][0]);
  return (d >= 0) == righthanded;
}
function isConvex ( pts , righthanded ) { // 'pts' is an [x,y] pair // 'righthanded' is a boolean if ( typeof ( righthanded ) === 'undefined' ) righthanded = true ; if ( pts . length != 3 ) throw new Error ( "This function requires an array of three points [x,y]" ) ; var d = ( pts [ 1 ] [ 0 ] - pts [ 0 ] [ 0 ] ) * ( pts [ 2 ] [ 1 ] - pts [ 0 ] [ 1 ] ) - ( pts [ 1 ] [ 1 ] - pts [ 0 ] [ 1 ] ) * ( pts [ 2 ] [ 0 ] - pts [ 0 ] [ 0 ] ) ; return ( d >= 0 ) == righthanded ; }
Function to determine if three consecutive points of a simple, non-self-intersecting ring make up a convex vertex, assuming the ring is right- or lefthanded
Function to determine if three consecutive points of a simple non - self - intersecting ring make up a convex vertex assuming the ring is right - or lefthanded