Пример #1
0
        static PolyLine2d merge_paths(PolyLine2d p1, PolyLine2d p2, double eps = MathUtil.Epsilon)
        {
            PolyLine2d pNew;

            if (p1.End.Distance(p2.Start) < eps)
            {
                pNew = new PolyLine2d(p1);
                pNew.AppendVertices(p2);
            }
            else if (p1.End.Distance(p2.End) < eps)
            {
                pNew = new PolyLine2d(p1);
                p2.Reverse();
                pNew.AppendVertices(p2);
            }
            else if (p1.Start.Distance(p2.Start) < eps)
            {
                p2.Reverse();
                pNew = new PolyLine2d(p2);
                pNew.AppendVertices(p1);
            }
            else if (p1.Start.Distance(p2.End) < eps)
            {
                pNew = new PolyLine2d(p2);
                pNew.AppendVertices(p1);
            }
            else
            {
                throw new Exception("shit");
            }

            return(pNew);
        }
Пример #2
0
        static PolyLine2d merge_paths(PolyLine2d p1, PolyLine2d p2, double eps = MathUtil.Epsilon)
        {
            PolyLine2d pNew;

            if (p1.End.Distance(p2.Start) < eps)
            {
                pNew = new PolyLine2d(p1);
                pNew.AppendVertices(p2);
            }
            else if (p1.End.Distance(p2.End) < eps)
            {
                pNew = new PolyLine2d(p1);
                p2.Reverse();
                pNew.AppendVertices(p2);
            }
            else if (p1.Start.Distance(p2.Start) < eps)
            {
                p2.Reverse();
                pNew = new PolyLine2d(p2);
                pNew.AppendVertices(p1);
            }
            else if (p1.Start.Distance(p2.End) < eps)
            {
                pNew = new PolyLine2d(p2);
                pNew.AppendVertices(p1);
            }
            else
            {
                throw new ArgumentException("Input polylines don't share an endpoint.");
            }
            return(pNew);
        }
Пример #3
0
        static Polygon2d to_loop(PolyLine2d p1, PolyLine2d p2, double eps = MathUtil.Epsilon)
        {
            Polygon2d p = new Polygon2d(p1.Vertices);

            if (p1.End.Distance(p2.Start) > eps)
            {
                p2.Reverse();
            }
            p.AppendVertices(p2);
            return(p);
        }
Пример #4
0
 public void Reverse()
 {
     Polyline.Reverse();
 }