예제 #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);
        }