Beispiel #1
0
        public static List <MyPoint3D> GetHeadlandIntersections(List <MyPoint3D> heanland, LineDefinition line, double width)
        {
            List <MyPoint3D> intersections = new List <MyPoint3D>();

            if (heanland.Last().X != heanland.First().X || heanland.Last().Y != heanland.First().Y)
            {
                var original = heanland;
                heanland = new List <MyPoint3D>();
                foreach (var p in original)
                {
                    heanland.Add(p);
                }
                heanland.Add(original.First());
            }
            for (int i = 1; i < heanland.Count; i++)
            {
                var p1           = heanland[i - 1];
                var p2           = heanland[i];
                var outerLine    = LineDefinition.GetLineDefinition(p1, p2);
                var intersection = LineDefinition.GetLineIntersection(outerLine, line);
                if (Utility.IsInLineSegment(p1, p2, intersection))
                {
                    intersections.Add(ChooseHeadlandIntersection(heanland, line, width, outerLine, intersection));
                }
            }
            if (intersections.Count % 2 != 0)
            {
            }
            return(intersections);
        }
Beispiel #2
0
        public static List <MyPoint3D> GetPolygonIntersections(List <MyPoint3D> polygon, LineDefinition line)
        {
            List <MyPoint3D> intersections = new List <MyPoint3D>();

            if (polygon.Last().X != polygon.First().X || polygon.Last().Y != polygon.First().Y)
            {
                var original = polygon;
                polygon = new List <MyPoint3D>();
                foreach (var p in original)
                {
                    polygon.Add(p);
                }
                polygon.Add(original.First());
            }
            for (int i = 1; i < polygon.Count; i++)
            {
                var p1           = polygon[i - 1];
                var p2           = polygon[i];
                var intersection = LineDefinition.GetLineIntersection(LineDefinition.GetLineDefinition(p1, p2), line);
                if (Utility.IsInLineSegment(p1, p2, intersection))
                {
                    intersections.Add(intersection);
                }
            }
            if (intersections.Count % 2 != 0)
            {
            }
            return(intersections);
        }
Beispiel #3
0
        public static MyPoint3D ShiftPoint(MyPoint3D p1, MyPoint3D p2, MyPoint3D p3, double Length)
        {
            LineDefinition line1;

            if (p1.X > p2.X)
            {
                line1 = LineDefinition.GetParallelLine(LineDefinition.GetLineDefinition(p1, p2), -Length);
            }
            else
            {
                line1 = LineDefinition.GetParallelLine(LineDefinition.GetLineDefinition(p1, p2), Length);
            }

            LineDefinition line2;

            if (p2.X > p3.X)
            {
                line2 = LineDefinition.GetParallelLine(LineDefinition.GetLineDefinition(p2, p3), -Length);
            }
            else
            {
                line2 = LineDefinition.GetParallelLine(LineDefinition.GetLineDefinition(p2, p3), Length);
            }

            if (line1.IsVertical && line2.IsVertical)
            {
                MyPoint3D p = new MyPoint3D();
                p.Y = p2.Y;
                if (p1.Y < p2.Y)
                {
                    p.X = p2.X - Length;
                }
                else
                {
                    p.X = p2.X + Length;
                }
                return(p);
            }
            else if (line1.k == line2.k)
            {
                return(ShiftPoint(p1, p2, -Length));
            }
            else
            {
                return(LineDefinition.GetLineIntersection(line1, line2));
            }
        }