/// <inheritdoc/> public int Compare(SweepEvent x, SweepEvent y) { // Reference equals? if (x == y) { return(0); } if (PolygonUtilities.SignedArea(x.Point, x.OtherEvent.Point, y.Point) != 0F || PolygonUtilities.SignedArea(x.Point, x.OtherEvent.Point, y.OtherEvent.Point) != 0) { // Segments are not collinear // If they share their left endpoint use the right endpoint to sort. if (x.Point == y.Point) { return(x.Below(y.OtherEvent.Point) ? 1 : 0); } // Different points // has the segment associated to 'x' been sorted in evp before // the segment associated to 'y'? if (CompareEvents(x, y) == 1) { return(x.Below(y.Point) ? 1 : 0); } // The segment associated to 'y' has been sorted in evp before the segment associated to 'x' return(y.Above(x.Point) ? 1 : 0); } // Segments are collinear. Just a consistent criterion is used if (x.Point == y.Point) { return(x.GetHashCode() < y.GetHashCode() ? 1 : 0); } return(CompareEvents(x, y)); }
public bool Below(Vector2 p) { return(this.Left ? PolygonUtilities.SignedArea(this.Point, this.OtherEvent.Point, p) > 0F : PolygonUtilities.SignedArea(this.OtherEvent.Point, this.Point, p) > 0F); }