Exemplo n.º 1
0
        public static CircularArc2D[] SplitCircularArc1(double x, double y, double radius, double startAngle, double sweepAngle, params double[] ts)
        {
            if (ts is null)
            {
                return(new[] { new CircularArc2D(x, y, radius, startAngle, sweepAngle) });
            }

            var filtered = ts.Where(t => t >= 0d && t <= 1d).Distinct().OrderBy(t => t).ToList();
            var start    = new CircularArc2D(x, y, radius, startAngle, sweepAngle);

            if (filtered.Count == 0)
            {
                return(new[] { start });
            }

            var tLast = 0d;
            var list  = new List <CircularArc2D>(filtered.Count + 1);

            foreach (var t in filtered)
            {
                var relT = 1d - ((1d - t) / (1d - tLast));
                tLast     = t;
                var(A, B) = BisectCircularArcTests.BisectCircularArc(x, y, radius, startAngle, sweepAngle, relT);
                list.Add(A);
                start = B;
            }

            list.Add(start);
            return(list.ToArray());
        }
Exemplo n.º 2
0
        public static CircularArc2D[] Split(double x, double y, double radius, params double[] ts)
        {
            if (ts is null)
            {
                return(new[] { OpenCircleTests.OpenCircle(x, y, radius, 0d) });
            }

            var filtered = ts.Where(t => t >= 0d && t <= 1d).Distinct().OrderBy(t => t).ToList();
            var arc      = OpenCircleTests.OpenCircle(x, y, radius, filtered[0]);

            if (filtered.Count == 0)
            {
                return(new[] { arc });
            }

            var tLast = 0d;
            var start = arc;
            var list  = new List <CircularArc2D>(filtered.Count + 1);

            foreach (var t in filtered)
            {
                var relT = 1d - ((1d - t) / (1d - tLast));
                tLast     = t;
                var(A, B) = BisectCircularArcTests.BisectCircularArc(arc.X, arc.Y, arc.Radius, arc.StartAngle, arc.SweepAngle, relT);
                list.Add(A);
                start = B;
            }

            list.Add(start);
            return(list.ToArray());
        }