Ejemplo n.º 1
0
        private static IEnumerable <Internal.ArcSegment> subdivide_arc_nicely(double start_angle, double end_angle)
        {
            // TODO: Should calculate number of subarcs without resorting to an enumeration

            if (start_angle > end_angle)
            {
                throw new System.ArgumentException("end_angle must be < than start angle", nameof(end_angle));
            }

            // the original purpose of this method is to break apart arcs > 90 degrees into smaller sub-arcs of 90 or less
            // the current implementation does that but also fractures the arc on 0,90,180,270, etc. degrees even if the arc length is <90
            // example (85,110) -> (85,90) & (90,110)

            double right_angle = System.Math.PI / 2;

            var cur = new Internal.ArcSegment(start_angle, end_angle);

            while (true)
            {
                double temp      = System.Math.Floor(cur.begin / right_angle);
                double cut_angle = (temp + 1) * right_angle;

                if ((cur.begin < cut_angle) && (cut_angle < cur.end))
                {
                    yield return(new Internal.ArcSegment(cur.begin, cut_angle));

                    cur = new Internal.ArcSegment(cut_angle, cur.end);
                }
                else
                {
                    yield return(cur);

                    break;
                }
            }
        }
        private static IEnumerable<Internal.ArcSegment> subdivide_arc_nicely(double start_angle, double end_angle)
        {
            // TODO: Should calculate number of subarcs without resorting to an enumeration

            if (start_angle > end_angle)
            {
                throw new System.ArgumentException("end_angle must be < than start angle", nameof(end_angle));
            }

            // the original purpose of this method is to break apart arcs > 90 degrees into smaller sub-arcs of 90 or less
            // the current implementation does that but also fractures the arc on 0,90,180,270, etc. degrees even if the arc length is <90
            // example (85,110) -> (85,90) & (90,110)

            double right_angle = System.Math.PI/2;

            var cur = new Internal.ArcSegment(start_angle, end_angle);
            while (true)
            {
                double temp = System.Math.Floor(cur.begin/right_angle);
                double cut_angle = (temp + 1)*right_angle;

                if ((cur.begin < cut_angle) && (cut_angle < cur.end))
                {
                    yield return (new Internal.ArcSegment(cur.begin, cut_angle));
                    cur = new Internal.ArcSegment(cut_angle, cur.end);
                }
                else
                {
                    yield return cur;
                    break;
                }
            }
        }