Exemple #1
0
        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));
        }
Exemple #2
0
        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);
        }
Exemple #3
0
 public T Cell(bool upper)
 {
     return((DoubleComparer.StaticCompare(xs, xe) < 0) == upper ? left : right);
 }
Exemple #4
0
        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));
        }
Exemple #5
0
            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);
            }