Example #1
0
        private static Queue <ArcPoint> arcsToPoints(Queue <Arc> arcs)
        {
            var acceptedArcs = new List <ArcInterval> {
                new ArcInterval(arcs.Dequeue())
            };

            while (arcs.Any())
            {
                var newArcs      = new List <ArcInterval>();
                var nextInterval = new ArcInterval(arcs.Dequeue());
                var nextPeriods  = new[]
                {
                    nextInterval,
                    nextInterval.PeriodicPrevious,
                    nextInterval.PeriodicNext
                };

                // Calculate intersection with previous arcs
                foreach (var newInterval in nextPeriods)
                {
                    foreach (var oldInterval in acceptedArcs.Where(arc => arc.Intersects(newInterval)))
                    {
                        newArcs.Add(new ArcInterval(
                                        newInterval.MaxAngle <oldInterval.MaxAngle?newInterval.Left : oldInterval.Left,
                                                              newInterval.MinAngle> oldInterval.MinAngle ? newInterval.Right: oldInterval.Right
                                        ));
                    }
                }
                acceptedArcs = newArcs;
            }

            return(new Queue <ArcPoint>(acceptedArcs.SelectMany(arc => new[] { arc.Right, arc.Left })));
        }
Example #2
0
 public bool Intersects(ArcInterval other)
 {
     return(this.MinAngle <= other.MaxAngle && this.MaxAngle >= other.MinAngle);
 }
Example #3
0
 public ArcInterval(ArcInterval original, double angleOffset)
 {
     this.Left  = new ArcPoint(original.Left, angleOffset);
     this.Right = new ArcPoint(original.Right, angleOffset);
 }