public int Compare(Edge <T> line1, Edge <T> line2) { double a1 = (line1.ye - line1.ys) / (line1.xe - line1.xs); double a2 = (line2.ye - line2.ys) / (line2.xe - line2.xs); double ya = a1 * (x - line1.xs) + line1.ys; double yb = a2 * (x - line2.xs) + line2.ys; int c = DoubleComparer.StaticCompare(ya, yb); return(c != 0 ? c : (compareToRight ? 1 : -1) * DoubleComparer.StaticCompare(a1, a2)); }
private void add(Edge <T> edge) { int c = DoubleComparer.StaticCompare(edge.xs, edge.xe); if (c == 0) { return; } endpoints.Add(new EndPoint(edge.xs, edge.ys, c < 0, count), edge); endpoints.Add(new EndPoint(edge.xe, edge.ye, c > 0, count++), edge); }
public T Cell(bool upper) { return((DoubleComparer.StaticCompare(xs, xe) < 0) == upper ? left : right); }
public int CompareTo(Edge <T> a) { double ya = (a.ye - a.ys) / (a.xe - a.xs) * (x - a.xs) + a.ys; return(DoubleComparer.StaticCompare(y, ya)); }
public int Compare(EndPoint a, EndPoint b) { int c = DoubleComparer.StaticCompare(a.x, b.x); return(c != 0 ? c : (a.start && !b.start) ? 1 : (!a.start && b.start) ? -1 : a.id <b.id ? -1 : a.id> b.id ? 1 : 0); }