Exemplo n.º 1
0
 public static bool CheckIfASegmentIntersectsAnotherSegment(Segment s)
 {
     var ls = SegmentsManager.Segments;
     foreach (var seg in ls.Where(seg => !seg.Egale(s)))
     {
         VerificaIntersectia = new Intersectie(seg.A, seg.B, s.A, s.B);
         if (VerificaIntersectia.Intersectation())
             return false;
     }
     return true;
 }
Exemplo n.º 2
0
        public static bool CheckIfASegmentIntersectsAnotherSegment(Segment s)
        {
            var ls = SegmentsManager.Segments;

            foreach (var seg in ls.Where(seg => !seg.Egale(s)))
            {
                VerificaIntersectia = new Intersectie(seg.A, seg.B, s.A, s.B);
                if (VerificaIntersectia.Intersectation())
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 3
0
 public static bool CheckIfTwoPointsIntersectAShapeTrapez(Point a, Point b)
 {
     for (var i = 0; i < PolygonManager.ListOfPolygons.Count; i++)
     {
         var ls = PolygonManager.ListOfPolygons[i].Segmente;
         foreach (var s in ls)
         {
             VerificaIntersectia = new Intersectie(s.A, s.B, a, b);
             if (VerificaIntersectia.Intersectation())
                 return true;
         }
     }
     return false;
 }
Exemplo n.º 4
0
 public static bool CheckIfTwoPointsIntersectAShapeTrapez(Point a, Point b)
 {
     for (var i = 0; i < PolygonManager.ListOfPolygons.Count; i++)
     {
         var ls = PolygonManager.ListOfPolygons[i].Segmente;
         foreach (var s in ls)
         {
             VerificaIntersectia = new Intersectie(s.A, s.B, a, b);
             if (VerificaIntersectia.Intersectation())
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 5
0
 public static bool CheckIfSegmentIntersectInteriorSegment(Segment s)
 {
     foreach (var seg in SegmentsManager.InteriorSegments)
     {
         if (!s.A.X.Equals(seg.A.X) && !s.A.X.Equals(seg.B.X) && !s.B.X.Equals(seg.A.X) && !s.B.X.Equals(seg.B.X))
         {
             VerificaIntersectia = new Intersectie(seg.A, seg.B, s.A, s.B);
             if (VerificaIntersectia.Intersectation())
             {
                 var pt = new Point(Convert.ToInt32(VerificaIntersectia.x), Convert.ToInt32(VerificaIntersectia.y));
                 if (!(pt.Equals(s.A) || pt.Equals(s.B)))
                     return true;
             }
         }
     }
     return false;
 }
Exemplo n.º 6
0
        public static bool CheckIfTwoPointsIntersectOnlyASpecificSegment(Point a, Point b, Segment s)
        {
            Segment s1 = new Segment(a, b);
            var     ls = SegmentsManager.Segments;

            foreach (var seg in ls.Where(seg => !seg.Egale(s1)))
            {
                if (!seg.Egale(s))
                {
                    VerificaIntersectia = new Intersectie(seg.A, seg.B, s1.A, s1.B);
                    if (VerificaIntersectia.Intersectation())
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 7
0
 public static bool CheckIfSegmentIntersectInteriorSegment(Segment s)
 {
     foreach (var seg in SegmentsManager.InteriorSegments)
     {
         if (!s.A.X.Equals(seg.A.X) && !s.A.X.Equals(seg.B.X) && !s.B.X.Equals(seg.A.X) && !s.B.X.Equals(seg.B.X))
         {
             VerificaIntersectia = new Intersectie(seg.A, seg.B, s.A, s.B);
             if (VerificaIntersectia.Intersectation())
             {
                 var pt = new Point(Convert.ToInt32(VerificaIntersectia.x), Convert.ToInt32(VerificaIntersectia.y));
                 if (!(pt.Equals(s.A) || pt.Equals(s.B)))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Exemplo n.º 8
0
        public static Point GetLastIntersectionPoint(Segment s)
        {
            var ls = GetAllSegmentesThatAreIntersectedByASegment(s);
            var lp = new List <Point>();

            foreach (var seg in ls)
            {
                var intersectie = new Intersectie(seg.A, seg.B, s.A, s.B);
                if (intersectie.Intersectation())
                {
                    intersectie.SetIntersectionPoint();
                    if (!double.IsNaN(intersectie.x) && !double.IsNaN(intersectie.y))
                    {
                        lp.Add(new Point(Convert.ToInt32(intersectie.x), Convert.ToInt32(intersectie.y)));
                    }
                }
            }
            lp = lp.OrderBy(p => p.Y).ToList();
            return(lp.Last());
        }
Exemplo n.º 9
0
        private static List <Segment> GetAllSegmentesThatAreIntersectedByASegment(Segment s)
        {
            var ls = new List <Segment>();

            foreach (var seg in SegmentsManager.Segments)
            {
                var intersectie = new Intersectie(seg.A, seg.B, s.A, s.B);
                if (intersectie.Intersectation())
                {
                    ls.Add(seg);
                }
            }
            foreach (var seg in PolygonManager.Contur.Segmente)
            {
                var intersectie = new Intersectie(seg.A, seg.B, s.A, s.B);
                if (intersectie.Intersectation())
                {
                    ls.Add(seg);
                }
            }
            return(ls);
        }
Exemplo n.º 10
0
 public static bool CheckIfTwoPointsIntersectOnlyASpecificSegment(Point a, Point b, Segment s)
 {
     Segment s1 = new Segment(a,b);
     var ls = SegmentsManager.Segments;
     foreach (var seg in ls.Where(seg => !seg.Egale(s1)))
     {
         if (!seg.Egale(s))
         {
             VerificaIntersectia = new Intersectie(seg.A, seg.B, s1.A, s1.B);
             if (VerificaIntersectia.Intersectation())
                 return false;
         }
     }
     return true;
 }
Exemplo n.º 11
0
 private static List<Segment> GetAllSegmentesThatAreIntersectedByASegment(Segment s)
 {
     var ls = new List<Segment>();
     foreach (var seg in SegmentsManager.Segments)
     {
         var intersectie = new Intersectie(seg.A, seg.B, s.A, s.B);
         if (intersectie.Intersectation())
             ls.Add(seg);
     }
     foreach (var seg in PolygonManager.Contur.Segmente)
     {
         var intersectie = new Intersectie(seg.A, seg.B, s.A, s.B);
         if (intersectie.Intersectation())
             ls.Add(seg);
     }
     return ls;
 }
Exemplo n.º 12
0
 public static Point GetLastIntersectionPoint(Segment s)
 {
     var ls = GetAllSegmentesThatAreIntersectedByASegment(s);
     var lp = new List<Point>();
     foreach (var seg in ls)
     {
         var intersectie = new Intersectie(seg.A, seg.B, s.A, s.B);
         if (intersectie.Intersectation())
         {
             intersectie.SetIntersectionPoint();
             if (!double.IsNaN(intersectie.x) && !double.IsNaN(intersectie.y))
                 lp.Add(new Point(Convert.ToInt32(intersectie.x), Convert.ToInt32(intersectie.y)));
         }
     }
     lp = lp.OrderBy(p => p.Y).ToList();
     return lp.Last();
 }