public void twist(Twist twist) { _cornerPosition = twist.apply(_cornerPosition, Type.Corners); _cornerOrientation = twist.apply(_cornerOrientation, Type.Corners, orientation: true); _edgePosition = twist.apply(_edgePosition, Type.Edges); _centerPosition = twist.apply(_centerPosition, Type.Centers); _twists.AddLast(twist); }
/// <summary> /// The Twist R2 equals two consecutive R twists. Consequently we /// can easily generate the corresponding permutation arrays by applying /// R twice. /// </summary> private Twist(string name, Twist twist, int num) { _name = name; cornerPermutation = Enumerable.Range(0, 8).ToArray(); centerPermutation = Enumerable.Range(0, 24).ToArray(); edgePermutation = Enumerable.Range(0, 24).ToArray(); pairPermutation = Enumerable.Range(0, 12).ToArray(); cornerOrientation = new int[8]; pairOrientation = new int[12]; edgeOrientation = new int[24]; for (int i = 0; i < num; i++) { cornerPermutation = twist.apply(cornerPermutation, Type.Corners); edgePermutation = twist.apply(edgePermutation, Type.Edges); centerPermutation = twist.apply(centerPermutation, Type.Centers); cornerOrientation = twist.apply(cornerOrientation, Type.Corners, orientation: true); pairPermutation = twist.apply(pairPermutation, Type.EdgePairs); pairOrientation = twist.apply(pairOrientation, Type.EdgePairs, orientation: true); edgeOrientation = twist.apply(edgeOrientation, Type.Edges, orientation: true); } // Set the inverse elements; the inverse used so the search algorithm // does not need to return and search where its coming from switch (num) { case 2: this.inverse = this; break; case 3: this.inverse = twist; twist.inverse = this; break; default: throw new SystemException("Not supported"); } }