Example #1
0
        private int EventCompare(bool p1IsStart, Point p11, Point p12, bool p2IsStart, Point p21, Point p22)
        {
            // compare the selected points first
            int comp = PointUtils.PointsCompare(p11, p21);

            if (comp != 0)
            {
                return(comp);
            }
            // the selected points are the same

            if (PointUtils.PointsSame(p12, p22)) // if the non-selected points are the same too...
            {
                return(0);                       // then the segments are equal
            }

            if (p1IsStart != p2IsStart)     // if one is a start and the other isn"t...
            {
                return(p1IsStart ? 1 : -1); // favor the one that isn"t the start
            }

            // otherwise, we"ll have to calculate which one is below the other manually
            return(PointUtils.PointAboveOrOnLine(p12,
                                                 p2IsStart ? p21 : p22, // order matters
                                                 p2IsStart ? p22 : p21
                                                 )
                ? 1
                : -1);
        }
Example #2
0
        private int StatusCompare(Node ev1, Node ev2)
        {
            Point a1 = ev1.Seg.Start;
            Point a2 = ev1.Seg.End;
            Point b1 = ev2.Seg.Start;
            Point b2 = ev2.Seg.End;

            if (PointUtils.PointsCollinear(a1, b1, b2))
            {
                if (PointUtils.PointsCollinear(a2, b1, b2))
                {
                    return(1);
                }
                return(PointUtils.PointAboveOrOnLine(a2, b1, b2) ? 1 : -1);
            }
            return(PointUtils.PointAboveOrOnLine(a1, b1, b2) ? 1 : -1);
        }