Esempio n. 1
0
        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);
        }
Esempio n. 2
0
            public ExplicitShape1 Intersection(ExplicitShape1 shape)
            {
                var newRect  = GridInterval.Intersection(storageBounds, shape.storageBounds);
                var newShape = ImplicitShape.Intersection(implicitShape, shape.implicitShape);

                return(new ExplicitShape1(newShape, newRect));
            }
Esempio n. 3
0
            public ExplicitShape1 Union(ExplicitShape1 shape)
            {
                var newRect  = GridInterval.UnionBoundingBox(storageBounds, shape.storageBounds);
                var newShape = ImplicitShape.Union(implicitShape, shape.implicitShape);

                return(new ExplicitShape1(newShape, newRect));
            }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
            public ExplicitShape3 Intersection(ExplicitShape3 shape2)
            {
                var newRect  = GridBounds.Intersection(storageBounds, shape2.storageBounds);
                var newShape = ImplicitShape.Intersection(implicitShape, shape2.implicitShape);

                return(new ExplicitShape3(newShape, newRect));
            }
Esempio n. 6
0
            public ExplicitShape3 Union(ExplicitShape3 shape2)
            {
                var newRect  = GridBounds.UnionBoundingBox(storageBounds, shape2.storageBounds);
                var newShape = ImplicitShape.Union(implicitShape, shape2.implicitShape);

                return(new ExplicitShape3(newShape, newRect));
            }
Esempio n. 7
0
            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));
            }
Esempio n. 8
0
        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));
        }
Esempio n. 9
0
            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));
            }
Esempio n. 10
0
        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));
        }
Esempio n. 11
0
        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));
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
 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));
 }
Esempio n. 14
0
 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));
 }
Esempio n. 15
0
            public ExplicitShape3 InverseInRect()
            {
                var newShape = ImplicitShape.Inverse(implicitShape);

                return(new ExplicitShape3(newShape, storageBounds));
            }