예제 #1
0
        public void isRedundantCW()
        {
            RotationSequence myList = new RotationSequence();

            myList.addRotation(new Rotation(Face.FRONT, Direction.CW));
            Assert.AreEqual(true, myList.isRedundant(new Rotation(Face.FRONT, Direction.CW)));
        }
예제 #2
0
        public static void findGoodRotationLinks(String p_firstFloorFile
                                                 , String p_secondFloorFile, String p_thirdFloorFile, int p_levels)
        {
            RubikFileWriter  l_firstWriter        = new RubikFileWriter(p_firstFloorFile);
            RubikFileWriter  l_secondWriter       = new RubikFileWriter(p_secondFloorFile);
            RubikFileWriter  l_thirdWriter        = new RubikFileWriter(p_thirdFloorFile);
            Cube             l_rubik              = new Cube();
            Cube             l_initialPermutation = new Cube(l_rubik);
            RotationSequence l_rotationLinkedList = new RotationSequence();

            GoodRotationsBuilder.BuildFilesForRotation(l_firstWriter, l_secondWriter, l_thirdWriter
                                                       , l_rubik, l_initialPermutation, l_rotationLinkedList, p_levels, "");
            l_firstWriter.close();
            l_secondWriter.close();
            l_thirdWriter.close();
        }
예제 #3
0
        public static void BuildFilesForRotation(RubikFileWriter p_firstFloorFile, RubikFileWriter p_secondFloorFile, RubikFileWriter p_thirdFloorFile
                                                 , Cube p_rubik
                                                 , Cube p_initialPermutation, RotationSequence p_rotationLinkedList, int p_level, String p_progressString)
        {
            if (p_level == 0)
            {
                return;
            }
            if (p_level > 5)
            {
                Console.WriteLine(p_progressString);
            }
            int i = 0;

            foreach (Face face in Enum.GetValues(typeof(Face)))
            {
                foreach (Direction direction in Enum.GetValues(typeof(Direction)))
                {
                    i++;
                    String   myProgressString = p_progressString + String.Format(".%d", i);
                    Rotation newRotation      = new Rotation(face, direction);
                    if (p_rotationLinkedList.isRedundant(newRotation))
                    {
                        continue;
                    }
                    p_rotationLinkedList.addRotation(newRotation);
                    p_rubik.rotateFace(newRotation.getFace(), newRotation.getDirection());
                    if (CubeStatus.isDifferentItemsInFirstFloorLessThanThree(p_rubik, p_initialPermutation))
                    {
                        p_rotationLinkedList.writeToFile(p_firstFloorFile);
                    }
                    if (CubeStatus.isDifferentItemsOnlyInSecondFloorLessThanThree(p_rubik, p_initialPermutation))
                    {
                        p_rotationLinkedList.writeToFile((p_secondFloorFile));
                    }
                    if (CubeStatus.changesOnlyInThirdFloor(p_rubik, p_initialPermutation))
                    {
                        p_rotationLinkedList.writeToFile(p_thirdFloorFile);
                    }

                    BuildFilesForRotation(p_firstFloorFile, p_secondFloorFile, p_thirdFloorFile,
                                          p_rubik, p_initialPermutation, p_rotationLinkedList, p_level - 1, myProgressString);
                    p_rotationLinkedList.removeRotation();
                    p_rubik.rotateFace(newRotation.getReverse().getFace(), newRotation.getReverse().getDirection());
                }
            }
        }
예제 #4
0
        public static Vector3d SetOrientation(RotationSequence seq, Point3D rotationAngles)
        {
            var axisX = new Vector3d(Vector3d.XAxis);
            var axisY = new Vector3d(Vector3d.YAxis);
            var axisZ = new Vector3d(Vector3d.ZAxis);

            switch (seq)
            {
            case RotationSequence.SequenceXYZ:
            {
                axisZ.Rotate(rotationAngles.X, axisX);
                axisX.Rotate(rotationAngles.Y, axisY);
                axisZ.Rotate(rotationAngles.Y, axisY);
                axisX.Rotate(rotationAngles.Z, axisZ);
                axisY.Rotate(rotationAngles.Z, axisZ);
                break;
            }

            case RotationSequence.SequenceXZY:
            {
                axisY.Rotate(rotationAngles.X, axisX);
                axisZ.Rotate(rotationAngles.X, axisX);
                axisX.Rotate(rotationAngles.Z, axisZ);
                axisY.Rotate(rotationAngles.Z, axisZ);
                axisX.Rotate(rotationAngles.Y, axisY);
                axisZ.Rotate(rotationAngles.Y, axisY);
                break;
            }

            case RotationSequence.SequenceYXZ:
            {
                axisX.Rotate(rotationAngles.Y, axisY);
                axisZ.Rotate(rotationAngles.Y, axisY);
                axisY.Rotate(rotationAngles.X, axisX);
                axisZ.Rotate(rotationAngles.X, axisX);
                axisX.Rotate(rotationAngles.Z, axisZ);
                axisY.Rotate(rotationAngles.Z, axisZ);
                break;
            }

            case RotationSequence.SequenceYZX:
            {
                axisX.Rotate(rotationAngles.Y, axisY);
                axisZ.Rotate(rotationAngles.Y, axisY);
                axisX.Rotate(rotationAngles.Z, axisZ);
                axisY.Rotate(rotationAngles.Z, axisZ);
                axisY.Rotate(rotationAngles.X, axisX);
                axisZ.Rotate(rotationAngles.X, axisX);
                break;
            }

            case RotationSequence.SequenceZXY:
            {
                axisX.Rotate(rotationAngles.Z, axisZ);
                axisY.Rotate(rotationAngles.Z, axisZ);
                axisY.Rotate(rotationAngles.X, axisX);
                axisZ.Rotate(rotationAngles.X, axisX);
                axisX.Rotate(rotationAngles.Y, axisY);
                axisZ.Rotate(rotationAngles.Y, axisY);
                break;
            }

            case RotationSequence.SequenceZYX:
            {
                axisX.Rotate(rotationAngles.Z, axisZ);
                axisY.Rotate(rotationAngles.Z, axisZ);
                axisX.Rotate(rotationAngles.Y, axisY);
                axisZ.Rotate(rotationAngles.Y, axisY);
                axisY.Rotate(rotationAngles.X, axisX);
                axisZ.Rotate(rotationAngles.X, axisX);
                break;
            }
            }
            // RFEM uses the positive axis z as the basis vector
            return(axisZ);
        }