using System.Collections.Generic; using Chernobyl.DesignPatterns.Extension; using Chernobyl.Mathematics.Movement; namespace Chernobyl.Mathematics.Geometry { /// /// A representation of a part of a curve that is bounded by two distinct /// end points and contains every point on the curve between its end points. /// The holds several instances /// that represent points along the arc. The first /// is the first end point and the last is the last /// end point. instances are ordered in this /// so that drawing an arc through these /// points in the order specified by this /// represents the actual arc. If an is stored at /// the beginning of the and at the end of it /// then the arc is a loop. If this has only /// two points then it is a straight line segment. /// public interface IArc : IEnumerable, IExtendable {} /// /// Utility methods for types implementing . /// public static class ArcExtensions { /// /// Breaks the instance down into the line segments /// that make up its length. /// /// The instance that is to be broken down into /// instances. /// The instances that define the /// passed in. public static IEnumerable ToLineSegments(this IArc arc) { using(IEnumerator arcEnumerator = arc.GetEnumerator()) { if(arcEnumerator.MoveNext() == true) { // First we must obtain the first line segment to start us off // with. ITransform previous = arcEnumerator.Current; while (arcEnumerator.MoveNext() == true) { yield return new LineSegment(previous, arcEnumerator.Current); previous = arcEnumerator.Current; } } } } } }