check to see if points are in counterclockwise order
963842
function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) {
		return (p2.y - p.y) * (p1.x - p.x) > (p1.y - p.y) * (p2.x - p.x);
	}
1071582
function calcSortedIntersections(lines,y) {
    var xlist = [];
    for(var i=0; i<lines.length; i++) {
        var A = lines[i].start;
        var B = lines[i].end;
        if(A.y<y && B.y>=y || B.y<y && A.y>=y) {
            var xval = A.x + (y-A.y) / (B.y-A.y) * (B.x-A.x);
            xlist.push(xval);
        }
    }
    return xlist.sort(function(a,b) {  return a-b; });
}
815844
def get_vert_opposites_per_edge(mesh_v, mesh_f):
    """"""
    result = {}
    for f in mesh_f:
        for i in range(3):
            key = [f[i], f[(i+1)%3]]
            key.sort()
            key = tuple(key)
            val = f[(i+2)%3]

            if key in result:
                result[key].append(val)
            else:
                result[key] = [val]
    return result
1292941
def _getLowestSyncPoint(self, syncPointList, subs):
        """"""
        if syncPointList[0].subNo == 0:
            return syncPointList[0]
        return SyncPoint(0, subs[0].start, subs[0].end)
20601
private void checkPossibleIslandsForRightOverlap(List<Island> possibleIslands) {
        Iterator<Island> candidates = possibleIslands.iterator();
        while (candidates.hasNext()) {
            Island island = candidates.next();
            // check whether there is complete overlap
            // if left end coordinate is not available there is no use in checking this island any longer
            if (doesCoordinateOverlapWithCommittedCoordinate(island.getLeftEnd())) {
                candidates.remove();
                continue;
            }
            // if right end coordinate is also available it means the whole island is available
            if (!doesCoordinateOverlapWithCommittedCoordinate(island.getRightEnd())) {
                // no further check necessary
                continue;
            }
            // remove this candidate from the possible islands
            candidates.remove();
            // partial overlap; find the starting point of the conflict
            Island smaller = findConflictingCoordinateAndCreateSmallerIslandSplitAtConflictingCoordinate(island);
            // add the smaller island to the priority queue
            // LOG.fine("Conflict detected! We add a smaller island! "+smaller);
            islandPriorityQueue.add(smaller);
        }
    }
1274908
def _topological_sort(self, targets):
    """"""

    target_set = set(targets)
    return [t for t in reversed(sort_targets(targets)) if t in target_set]
888421
public boolean hasVertex(float x, float y) {    	
    	if (points.length == 0) {
    		return false;
    	}
    	
    	checkPoints();
    	
    	for (int i=0;i<points.length;i+=2) {
    		if ((points[i] == x) && (points[i+1] == y)) {
    			return true;
    		}
    	}
    	
    	return false;
    }
692749
function boolIntersects(coords1,coords2) {
    
  
    // if (coords1.length !== 2)throw new Error("<intersects> line1 must only contain 2 coordinates");
    // if (coords2.length !== 2)throw new Error("<intersects> line2 must only contain 2 coordinates");
    const x1 = coords1[0][0];
    const y1 = coords1[0][1];
    const x2 = coords1[1][0];
    const y2 = coords1[1][1];
    const x3 = coords2[0][0];
    const y3 = coords2[0][1];
    const x4 = coords2[1][0];
    const y4 = coords2[1][1];
    const denom = ((y4 - y3) * (x2 - x1)) - ((x4 - x3) * (y2 - y1));
    const numeA = ((x4 - x3) * (y1 - y3)) - ((y4 - y3) * (x1 - x3));
    const numeB = ((x2 - x1) * (y1 - y3)) - ((y2 - y1) * (x1 - x3));

    if (denom === 0) return null;
    
    const uA = numeA / denom;
    const uB = numeB / denom;

    if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1)return true;
    return null;
}
748965
private void rotateTwiceOrdered() {
		Point2D_F64 a = ordered[0];
		Point2D_F64 b = ordered[1];
		Point2D_F64 c = ordered[2];
		Point2D_F64 d = ordered[3];

		ordered[0] = c;
		ordered[1] = d;
		ordered[2] = a;
		ordered[3] = b;
	}
407099
function compareObjects (x, y) {
    const keysX = Object.keys(x)
    const keysY = Object.keys(y)

    // compare keys
    keysX.sort(naturalSort)
    keysY.sort(naturalSort)
    const c = compareArrays(keysX, keysY)
    if (c !== 0) {
      return c
    }

    // compare values
    for (let i = 0; i < keysX.length; i++) {
      const v = compareNatural(x[keysX[i]], y[keysY[i]])
      if (v !== 0) {
        return v
      }
    }

    return 0
  }
1196403
def check_overlap(current, hit, overlap = 200):
    
    for prev in current:
        p_coords = prev[2:4]
        coords = hit[2:4]
        if get_overlap(coords, p_coords) >= overlap:
            return True
    return False
338510
boolean isVertex(double x, double y)
    {
        int cnt = points.numRows;
        double[] d = points.data;
        for (int ii=0;ii<cnt;ii++)
        {
            if (x == d[2*ii] && y== d[2*ii+1])
            {
                return true;
            }
        }
        return false;
    }
1181431
def check_on_curve(self):
        """"""
        if not self._curve.contains_point(*self):
            raise NoSuchPointError('({},{}) is not on the curve {}'.format(self[0], self[1], self._curve))
845649
function isPointOverlap(p0, p1) {
            return ceil(p0.x) === ceil(p1.x) && ceil(p0.y) === ceil(p1.y);
        }
574072
def isInside(self, point, tol=0.0001):
        
        poly = self.polydata(True)
        points = vtk.vtkPoints()
        points.InsertNextPoint(point)
        pointsPolydata = vtk.vtkPolyData()
        pointsPolydata.SetPoints(points)
        sep = vtk.vtkSelectEnclosedPoints()
        sep.SetTolerance(tol)
        sep.CheckSurfaceOff()
        sep.SetInputData(pointsPolydata)
        sep.SetSurfaceData(poly)
        sep.Update()
        return sep.IsInside(0)
81149
def comparator(self, x, y):
        '''
        

        '''

        indX=0
        indY=0
        for i in range(len(self.stable_names)):
            if self.stable_names[i] == x[0].split('-')[0]:
                indX=i
            if self.stable_names[i] == y[0].split('-')[0]:
                indY=i

        if indX>indY:
            return 1
        if indX==indY:
            return 0
        if indX<indY:
            return -1
199326
def FindNotNaNBackwards(x, i):
    """"""
    while i >= 0:
        if not np.isnan(x[i]):
            return i
        i -= 1
    return -1