Exemplo n.º 1
0
        public void testFaceGetOpposite()
        {
            Face myFace = Face.BOTTOM;

            Assert.AreEqual(Face.TOP, FaceHandler.getOpposite(myFace));
            myFace = Face.FRONT;
            Assert.AreEqual(Face.BACK, FaceHandler.getOpposite(myFace));
            myFace = Face.RIGHT;
            Assert.AreEqual(Face.LEFT, FaceHandler.getOpposite(myFace));
            myFace = Face.TOP;
            Assert.AreEqual(Face.BOTTOM, FaceHandler.getOpposite(myFace));
            myFace = Face.BACK;
            Assert.AreEqual(Face.FRONT, FaceHandler.getOpposite(myFace));
            myFace = Face.LEFT;
            Assert.AreEqual(Face.RIGHT, FaceHandler.getOpposite(myFace));
        }
Exemplo n.º 2
0
        public Boolean isRedundant(Rotation p_rotation)
        {
            Boolean l_returnValue = false;

            Face      l_lastFace;
            Direction l_lastDirection;

            if (c_array.Count > 0)
            {
                l_lastFace      = c_array[(c_array.Count - 1)].getFace();
                l_lastDirection = c_array[c_array.Count - 1].getDirection();
                // new rotation is opposite to previous
                if (c_array[c_array.Count - 1].getReverse().equals(p_rotation))
                {
                    l_returnValue = true;
                }
                // previous face was opposite and previous face greater then current face
                if ((p_rotation.getFace() == FaceHandler.getOpposite(l_lastFace) && ((int)l_lastFace > (int)p_rotation.getFace())))
                {
                    l_returnValue = true;
                }
                // two clockwise rotation of same face
                if ((p_rotation.getFace() == l_lastFace) && (l_lastDirection == Direction.CW) &&
                    (p_rotation.getDirection() == Direction.CW))
                {
                    l_returnValue = true;
                }
                //no three counter clockwise rotations
                if (c_array.Count > 1)
                {
                    if ((p_rotation.getFace() == l_lastFace) && (l_lastDirection == Direction.CCW) &&
                        (p_rotation.getDirection() == Direction.CCW) &&
                        (c_array[c_array.Count - 2].getFace() == l_lastFace) && (l_lastDirection == Direction.CCW) &&
                        (c_array[c_array.Count - 2].getDirection() == Direction.CCW))
                    {
                        l_returnValue = true;
                    }
                }
            }
            else
            {
                l_returnValue = false;
            }
            return(l_returnValue);
        }