private IEnumerable <PolygonChanged> OutGoingForPointRange(int index, int range) { var polygonMutations = Diagonalizes.DiagonalizeListRate(ListUtil.FromTo(index, index + range - 1).SelectList(i => GetPointMutationsForIndex(i % Polygon.Points.Count)), 2).ConcatUtil().Select(xs => CombinePointMutations(xs.ToLazyList())); var changedPolygons = polygonMutations.Select(polygon => new PolygonChanged(polygon, 0)); var withoutSelfIntersections = changedPolygons.Where(changedPolygon => !changedPolygon.NewPolygon.IsSelfIntersecting()); return(withoutSelfIntersections); }
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); }