Пример #1
0
        public static List <HandCurve> Combine(HandCurve handCurve1, HandCurve handCurve2)
        {
            if (!(handCurve1.curve is OpenCurve))
            {
                throw new System.Exception("handCurve1 must be open");
            }
            if (!(handCurve2.curve is OpenCurve))
            {
                throw new System.Exception("handCurve2 must be open");
            }

            (OpenCurve curve1, OpenCurve curve2) = AdjustOrientation((OpenCurve)handCurve1.curve, (OpenCurve)handCurve2.curve);

            List <HandCurve>        newHandCurves = new List <HandCurve>();
            IReadOnlyList <Vector3> points1       = curve1.GetPoints();
            IReadOnlyList <Vector3> points2       = curve2.GetPoints();

            if (Vector3.Distance(points1.Last(), points2.First()) < collision)
            {
                OpenCurve newCurve = curve1.Concat(curve2);
                bool      closed   = newCurve.DistanceOfFirstAndLast() < collision;
                newHandCurves.Add(new HandCurve(newCurve.ChangeClosed(closed), selected: true));
            }

            return(newHandCurves);
        }
Пример #2
0
        private static (OpenCurve, OpenCurve) AdjustOrientation(OpenCurve curve1, OpenCurve curve2)
        {
            var points1 = curve1.GetPoints();
            var points2 = curve2.GetPoints();

            if (Vector3.Distance(points1.Last(), points2.Last()) < collision)
            {
                return(curve1, curve2.Reversed());
            }
            else if (Vector3.Distance(points1.First(), points2.First()) < collision)
            {
                return(curve1.Reversed(), curve2);
            }
            else if (Vector3.Distance(points1.First(), points2.Last()) < collision)
            {
                return(curve1.Reversed(), curve2.Reversed());
            }
            else
            {
                return(curve1, curve2);
            }
        }