コード例 #1
0
ファイル: SweepEventSet.cs プロジェクト: VadimCat/Map-project
        private bool SegmentCompare(SweepEvent e1, SweepEvent e2)
        {
            if (e1.Equals(e2))
            {
                return(false);
            }

            if (signedArea(e1.p, e1.otherSE.p, e2.p) != 0 || signedArea(e1.p, e1.otherSE.p, e2.otherSE.p) != 0)
            {
                // Segments are not collinear
                // If they share their left endpoint use the right endpoint to sort
                if (Misc.PointEquals(e1.p, e2.p))
                {
                    return(e1.isBelow(e2.otherSE.p));
                }

                if (CompareSweepEvent(e1, e2))
                {
                    return(e2.isAbove(e1.p));
                }

                return(e1.isBelow(e2.p));
            }

            if (Misc.PointEquals(e1.p, e2.p))             // Segments colinear
            {
                return(false);
            }

            return(CompareSweepEvent(e1, e2));
        }
コード例 #2
0
ファイル: SweepEventSet.cs プロジェクト: VadimCat/Map-project
        // Should only be called by segmentCompare
        private bool CompareSweepEvent(SweepEvent e1, SweepEvent e2)
        {
            if (e1.p.x > e2.p.x)             // Different x coordinate
            {
                return(true);
            }

            if (e2.p.x > e1.p.x)             // Different x coordinate
            {
                return(false);
            }

            if (e1.p != e2.p)             // Different points, but same x coordinate. The event with lower y coordinate is processed first
            {
                return(e1.p.y > e2.p.y);
            }

            if (e1.isLeft != e2.isLeft)             // Same point, but one is a left endpoint and the other a right endpoint. The right endpoint is processed first
            {
                return(e1.isLeft);
            }

            // Same point, both events are left endpoints or both are right endpoints. The event associate to the bottom segment is processed first
            return(e1.isAbove(e2.otherSE.p));
        }
コード例 #3
0
        bool Sec(SweepEvent e1, SweepEvent e2)
        {
            // Different x coordinate
            if (e1.p.x != e2.p.x)
            {
                return(e1.p.x > e2.p.x);
            }

            // Same x coordinate. The event with lower y coordinate is processed first
            if (e1.p.y != e2.p.y)
            {
                return(e1.p.y > e2.p.y);
            }

            // Same point, but one is a left endpoint and the other a right endpoint. The right endpoint is processed first
            if (e1.isLeft != e2.isLeft)
            {
                return(e1.isLeft);
            }

            // Same point, both events are left endpoints or both are right endpoints. The event associate to the bottom segment is processed first
            return(e1.isAbove(e2.otherSE.p));
        }