private IEnumerable <PointMutation> GetPointMutationsForIndex(int index)
        {
            var removedPointPolygons    = ListUtil.Singleton((PointMutation) new DeletedPoint(index));
            var changedPointPolygons    = MutatePoint(index);
            var insertedPointPolygons   = EnumerableUtil.From(0).Select(i => InsertPoint(index));
            var changedInserted         = EnumerableUtil.ConcatUtil(changedPointPolygons, insertedPointPolygons);
            var changedInsertedDiagonal = Diagonalizes.DiagonalizeListRateEmpty(changedInserted, 2).ConcatUtil().Select(xs => CombineAddedChangedMutations(xs.ToLazyList()));
            var combined = removedPointPolygons.Concat(changedInsertedDiagonal);

            return(combined);
        }
Exemple #2
0
        public IEnumerable <PolygonChanged> OutGoingForPoint(int index)
        {
            var changedPointPolygons  = MutatePoint(index);
            var insertedPointPolygons = InsertPoint(index);
            var removedPointPolygons  = ListUtil.Singleton(RemovePoint(index));
            var changeInsertPolygons  = ListUtil.New <IEnumerable <IList <PolygonChanged> > >(
                changedPointPolygons.DivideInfinite(CHANGES_PER_INSERT), insertedPointPolygons.Select(
                    x => ListUtil.New(x))).Intertwine().SelectMany(x => x);
            var combined = removedPointPolygons.Concat(changeInsertPolygons);

            return(combined.Where(x => !x.NewPolygon.IsSelfIntersecting()));
        }
        private IEnumerable <PointMutation> InsertPoint(int pointIndex)
        {
            var mid = (Polygon.Points[pointIndex] + Polygon.Points[(pointIndex + 1) % Polygon.Points.Count]) / 2;

            return(discreteSpiralPointMutation.SpiralPoints(mid).Select(point => (PointMutation) new AddedPoints(pointIndex, ListUtil.Singleton(point))));
        }