static int partition(int low, int high) { AEL pivot = _ael[high]; // index of smaller element int i = (low - 1); for (int j = low; j < high; j++) { // If current element is smaller // than the pivot if (_ael[j].xIntersect < pivot.xIntersect) { i++; // swap arr[i] and arr[j] AEL temp = _ael[i]; _ael[i] = _ael[j]; _ael[j] = temp; } } // swap arr[i+1] and arr[high] (or pivot) AEL temp1 = _ael[i + 1]; _ael[i + 1] = _ael[high]; _ael[high] = temp1; return(i + 1); }
static void pushEdge(Edge edge) { int _yUpper = edge.pBefore.Y > edge.pAfter.Y ? edge.pBefore.Y : edge.pAfter.Y; //y of point has y_upper float _xIntersect = edge.pBefore.Y > edge.pAfter.Y ? edge.pAfter.X : edge.pBefore.X; //x of point has y_lower float _reciSlope = (float)(edge.pBefore.X - edge.pAfter.X) / (edge.pBefore.Y - edge.pAfter.Y); AEL aelTemp = new AEL(_yUpper, _xIntersect, _reciSlope); _ael.Add(aelTemp); }