Exemplo n.º 1
0
        /// <summary>
        /// Generates 3D cubes from the Rubik cubes
        /// </summary>
        /// <returns>Cubes from the Rubik converted to 3D cubes</returns>
        private List <Cube3D> GenCubes3D()
        {
            List <Cube> cubes = this.Rubik.Cubes;

            List <Cube3D> cubes3D = new List <Cube3D>();
            double        d       = 2.0 / 3.0;

            foreach (Cube c in cubes)
            {
                Cube3D cr = new Cube3D(new Point3D(d * CubeFlagService.ToInt(c.Position.X), d * CubeFlagService.ToInt(c.Position.Y), d * CubeFlagService.ToInt(c.Position.Z)), d / 2, c.Position.Flags, c.Faces);
                if (cr.Position.HasFlag(CubeFlag.TopLayer))
                {
                    cr = cr.Rotate(RotationType.Y, LayerRotation[CubeFlag.TopLayer], new Point3D(0, d, 0));
                }
                if (cr.Position.HasFlag(CubeFlag.MiddleLayer))
                {
                    cr = cr.Rotate(RotationType.Y, LayerRotation[CubeFlag.MiddleLayer], new Point3D(0, 0, 0));
                }
                if (cr.Position.HasFlag(CubeFlag.BottomLayer))
                {
                    cr = cr.Rotate(RotationType.Y, LayerRotation[CubeFlag.BottomLayer], new Point3D(0, -d, 0));
                }
                if (cr.Position.HasFlag(CubeFlag.FrontSlice))
                {
                    cr = cr.Rotate(RotationType.Z, LayerRotation[CubeFlag.FrontSlice], new Point3D(0, 0, d));
                }
                if (cr.Position.HasFlag(CubeFlag.MiddleSlice))
                {
                    cr = cr.Rotate(RotationType.Z, LayerRotation[CubeFlag.MiddleSlice], new Point3D(0, 0, 0));
                }
                if (cr.Position.HasFlag(CubeFlag.BackSlice))
                {
                    cr = cr.Rotate(RotationType.Z, LayerRotation[CubeFlag.BackSlice], new Point3D(0, 0, -d));
                }
                if (cr.Position.HasFlag(CubeFlag.LeftSlice))
                {
                    cr = cr.Rotate(RotationType.X, LayerRotation[CubeFlag.LeftSlice], new Point3D(-d, 0, 0));
                }
                if (cr.Position.HasFlag(CubeFlag.MiddleSliceSides))
                {
                    cr = cr.Rotate(RotationType.X, LayerRotation[CubeFlag.MiddleSliceSides], new Point3D(0, 0, 0));
                }
                if (cr.Position.HasFlag(CubeFlag.RightSlice))
                {
                    cr = cr.Rotate(RotationType.X, LayerRotation[CubeFlag.RightSlice], new Point3D(d, 0, 0));
                }

                cr = cr.Rotate(RotationType.Y, this.Rotation[1], new Point3D(0, 0, 0));
                cr = cr.Rotate(RotationType.Z, this.Rotation[2], new Point3D(0, 0, 0));
                cr = cr.Rotate(RotationType.X, this.Rotation[0], new Point3D(0, 0, 0));
                cubes3D.Add(cr);
            }
            return(cubes3D);
        }
        /// <summary>
        /// Generates 3D cubes from the Rubik cubes
        /// </summary>
        /// <returns>Cubes from the Rubik converted to 3D cubes</returns>
        private List<Cube3D> GenCubes3D()
        {
            List<Cube> cubes = this.Rubik.Cubes;

              List<Cube3D> cubes3D = new List<Cube3D>();
              double d = 2.0 / 3.0;
              foreach (Cube c in cubes)
              {
            Cube3D cr = new Cube3D(new Point3D(d * CubeFlagService.ToInt(c.Position.X), d * CubeFlagService.ToInt(c.Position.Y), d * CubeFlagService.ToInt(c.Position.Z)), d / 2, c.Position.Flags, c.Faces);
            if (cr.Position.HasFlag(CubeFlag.TopLayer))
              cr = cr.Rotate(RotationType.Y, LayerRotation[CubeFlag.TopLayer], new Point3D(0, d, 0));
            if (cr.Position.HasFlag(CubeFlag.MiddleLayer))
              cr = cr.Rotate(RotationType.Y, LayerRotation[CubeFlag.MiddleLayer], new Point3D(0, 0, 0));
            if (cr.Position.HasFlag(CubeFlag.BottomLayer))
              cr = cr.Rotate(RotationType.Y, LayerRotation[CubeFlag.BottomLayer], new Point3D(0, -d, 0));
            if (cr.Position.HasFlag(CubeFlag.FrontSlice))
              cr = cr.Rotate(RotationType.Z, LayerRotation[CubeFlag.FrontSlice], new Point3D(0, 0, d));
            if (cr.Position.HasFlag(CubeFlag.MiddleSlice))
              cr = cr.Rotate(RotationType.Z, LayerRotation[CubeFlag.MiddleSlice], new Point3D(0, 0, 0));
            if (cr.Position.HasFlag(CubeFlag.BackSlice))
              cr = cr.Rotate(RotationType.Z, LayerRotation[CubeFlag.BackSlice], new Point3D(0, 0, -d));
            if (cr.Position.HasFlag(CubeFlag.LeftSlice))
              cr = cr.Rotate(RotationType.X, LayerRotation[CubeFlag.LeftSlice], new Point3D(-d, 0, 0));
            if (cr.Position.HasFlag(CubeFlag.MiddleSliceSides))
              cr = cr.Rotate(RotationType.X, LayerRotation[CubeFlag.MiddleSliceSides], new Point3D(0, 0, 0));
            if (cr.Position.HasFlag(CubeFlag.RightSlice))
              cr = cr.Rotate(RotationType.X, LayerRotation[CubeFlag.RightSlice], new Point3D(d, 0, 0));

            cr = cr.Rotate(RotationType.Y, this.Rotation[1], new Point3D(0, 0, 0));
            cr = cr.Rotate(RotationType.Z, this.Rotation[2], new Point3D(0, 0, 0));
            cr = cr.Rotate(RotationType.X, this.Rotation[0], new Point3D(0, 0, 0));
            cubes3D.Add(cr);
              }
              return cubes3D;
        }
        /// <summary>
        /// Generates 3D cubes from the Rubik cubes
        /// </summary>
        /// <returns>Cubes from the Rubik converted to 3D cubes</returns>
        private IEnumerable<Cube3D> GenCubes3D()
        {
            var cubes = this.Rubik.Cubes;

            var cubes3D = new List<Cube3D>();
            const double D = 2.0 / 3.0;
            foreach (var c in cubes)
            {
                var cr = new Cube3D(new Point3D(D * CubeFlagService.ToInt(c.Position.X), D * CubeFlagService.ToInt(c.Position.Y), D * CubeFlagService.ToInt(c.Position.Z)), D / 2, c.Position.Flags, c.Faces);
                if (cr.Position.HasFlag(CubeFlag.TopLayer))
                    cr = cr.Rotate(RotationType.Y, this.LayerRotation[CubeFlag.TopLayer], new Point3D(0, D, 0));
                if (cr.Position.HasFlag(CubeFlag.MiddleLayer))
                    cr = cr.Rotate(RotationType.Y, this.LayerRotation[CubeFlag.MiddleLayer], new Point3D(0, 0, 0));
                if (cr.Position.HasFlag(CubeFlag.BottomLayer))
                    cr = cr.Rotate(RotationType.Y, this.LayerRotation[CubeFlag.BottomLayer], new Point3D(0, -D, 0));
                if (cr.Position.HasFlag(CubeFlag.FrontSlice))
                    cr = cr.Rotate(RotationType.Z, this.LayerRotation[CubeFlag.FrontSlice], new Point3D(0, 0, D));
                if (cr.Position.HasFlag(CubeFlag.MiddleSlice))
                    cr = cr.Rotate(RotationType.Z, this.LayerRotation[CubeFlag.MiddleSlice], new Point3D(0, 0, 0));
                if (cr.Position.HasFlag(CubeFlag.BackSlice))
                    cr = cr.Rotate(RotationType.Z, this.LayerRotation[CubeFlag.BackSlice], new Point3D(0, 0, -D));
                if (cr.Position.HasFlag(CubeFlag.LeftSlice))
                    cr = cr.Rotate(RotationType.X, this.LayerRotation[CubeFlag.LeftSlice], new Point3D(-D, 0, 0));
                if (cr.Position.HasFlag(CubeFlag.MiddleSliceSides))
                    cr = cr.Rotate(RotationType.X, this.LayerRotation[CubeFlag.MiddleSliceSides], new Point3D(0, 0, 0));
                if (cr.Position.HasFlag(CubeFlag.RightSlice))
                    cr = cr.Rotate(RotationType.X, this.LayerRotation[CubeFlag.RightSlice], new Point3D(D, 0, 0));

                cr = cr.Rotate(RotationType.Y, this.Rotation[1], new Point3D(0, 0, 0));
                cr = cr.Rotate(RotationType.Z, this.Rotation[2], new Point3D(0, 0, 0));
                cr = cr.Rotate(RotationType.X, this.Rotation[0], new Point3D(0, 0, 0));
                cubes3D.Add(cr);
            }

            return cubes3D;
        }