public static IExplicitShape <GridPoint3> Translate(this IExplicitShape <GridPoint3> shape, GridPoint3 n) { var newBounds = GridBounds.Translate(shape.Bounds, n); var newShape = ImplicitShape.Translate(shape, n).ToExplicit(newBounds); return(newShape); }
public ExplicitShape1 Intersection(ExplicitShape1 shape) { var newRect = GridInterval.Intersection(storageBounds, shape.storageBounds); var newShape = ImplicitShape.Intersection(implicitShape, shape.implicitShape); return(new ExplicitShape1(newShape, newRect)); }
public ExplicitShape1 Union(ExplicitShape1 shape) { var newRect = GridInterval.UnionBoundingBox(storageBounds, shape.storageBounds); var newShape = ImplicitShape.Union(implicitShape, shape.implicitShape); return(new ExplicitShape1(newShape, newRect)); }
public static IExplicitShape <int> Translate(this IExplicitShape <int> shape, int n) { var newBounds = GridInterval.Translate(shape.Bounds, n); var newShape = ImplicitShape.Translate(shape, n).ToExplicit(newBounds); return(newShape); }
public ExplicitShape3 Intersection(ExplicitShape3 shape2) { var newRect = GridBounds.Intersection(storageBounds, shape2.storageBounds); var newShape = ImplicitShape.Intersection(implicitShape, shape2.implicitShape); return(new ExplicitShape3(newShape, newRect)); }
public ExplicitShape3 Union(ExplicitShape3 shape2) { var newRect = GridBounds.UnionBoundingBox(storageBounds, shape2.storageBounds); var newShape = ImplicitShape.Union(implicitShape, shape2.implicitShape); return(new ExplicitShape3(newShape, newRect)); }
public ExplicitShape1 Translate(int offset) { var map = Map.Translate(offset); var newRect = GridInterval.Translate(storageBounds, offset); var newShape = ImplicitShape.Transform(implicitShape, map); return(new ExplicitShape1(newShape, newRect)); }
public static IExplicitShape <GridPoint3> Layer(this IExplicitShape <GridPoint2> shape, int layerCount) { var bounds = shape.Bounds; var newBounds = new GridBounds(bounds.Point.To3DXY(0), bounds.Size.To3DXY(layerCount)); // static call is necessary so that this method does not get called instead //Remember: explicit shapes _are_ implicit shapes too. return(ImplicitShape.Layer(shape, layerCount).ToExplicit(newBounds)); }
public ExplicitShape3 Translate(GridPoint3 offset) { var map = Map.Translate(offset); var newRect = GridBounds.Translate(storageBounds, offset); var newShape = ImplicitShape.Transform(implicitShape, map); return(new ExplicitShape3(newShape, newRect)); }
public static IExplicitShape <GridPoint3> SwapToZYX(this IExplicitShape <GridPoint3> shape) { var bounds = shape.Bounds; var point = bounds.Point; var size = bounds.Size; var newBounds = new GridBounds( new GridPoint3(point.Z, point.Y, point.X), new GridPoint3(size.Z, size.Y, size.X)); return(ImplicitShape.SwapToZYX(shape).ToExplicit(newBounds)); }
public static IExplicitShape <GridPoint2> SwapXY(this IExplicitShape <GridPoint2> shape) { var bounds = shape.Bounds; var point = bounds.Point; var size = bounds.Size; var newBounds = new GridRect( new GridPoint2(point.Y, point.X), new GridPoint2(size.Y, size.X)); return(ImplicitShape.SwapXY(shape).ToExplicit(newBounds)); }
public static Grid2 <float> ImageToGreyScaleGrid(Texture2D texture, int xOffset, int yOffset) { var dimensions = new GridPoint2(texture.width, texture.height); var storageRect = new GridRect(GridPoint2.Zero, dimensions); var implicitShape = ImplicitShape.Parallelogram(dimensions); var explicitShape = implicitShape.ToExplicit(storageRect); var grid = new Grid2 <float>(explicitShape); var textureData = texture.GetPixels().Select(c => c.grayscale).ToArray(); grid.Fill(p => textureData[(p.X + xOffset) % texture.width + (texture.width * ((p.Y + yOffset) % texture.height))]); return(grid); }
public static IExplicitShape <GridPoint3> Select(this IExplicitShape <GridPoint3> shape, Func <GridPoint3, bool> predicate) { return(ImplicitShape .Func <GridPoint3>(x => shape.Contains(x) && predicate(x)) .ToExplicit(shape.Bounds)); }
public static IExplicitShape <int> Where(this IExplicitShape <int> shape, Func <int, bool> predicate) { return(ImplicitShape .Func <int>(x => shape.Contains(x) && predicate(x)) .ToExplicit(shape.Bounds)); }
public ExplicitShape3 InverseInRect() { var newShape = ImplicitShape.Inverse(implicitShape); return(new ExplicitShape3(newShape, storageBounds)); }