CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.rubik
Class Cubes

java.lang.Object
  extended by ch.randelshofer.rubik.Cubes

public class Cubes
extends java.lang.Object

This class provides static utility methods for Cube objects.

Version:
2.4 2010-04-06 Added create-method.
2.3 2008-09-03 Return a readable permutation string, even if a notation does not support it.
2.2 2008-02-23 Method getVisibleOrder returned incorrect values for cubes which have more than 3 layers.
2.1 2008-01-06 Split method toPermutationString up into multiple methods.
2.0 2008-12-30 Adapted to changes in AbstractCube. Rewrote method toPermutationString.
1.1 2007-11-04 Implemented methods getNormalizedStickersString and getMappedStickersString for 3x3 cubes.
1.0 January 3, 2006 Created.
Author:
Werner Randelshofer

Method Summary
static Cube create(int layerCount)
          Creates a cube with the specified layer count.
static int getFaceOfSticker(CubeAttributes attr, int stickerIndex)
           
static int[][] getMappedStickers(Cube cube, int[] mappings)
          Returns the stickers reflecting the current permutation of the cube.
static int[][] getMappedStickers(Cube cube, int[][] mappings)
          Returns the stickers reflecting the current permutation of the cube.
static int getOrder(Cube cube)
          Returns a number that describes the order of the permutation of the supplied cube.
static int getVisibleOrder(Cube cube)
          Returns a number that describes the order of the permutation of the supplied cube, assuming that all stickers only have a solid color, and that all stickers on the same face have the same color.
static void setToStickers(Cube cube, int[] stickers)
          Sets the cube to the specified stickers.
static java.lang.String toCornerPermutationString(Cube cube)
           
static java.lang.String toCornerPermutationString(Cube cube, Notation notation)
           
static java.lang.String toEdgePermutationString(Cube cube)
           
static java.lang.String toEdgePermutationString(Cube cube, Notation notation)
           
static java.lang.String toMappedStickersString(Cube cube, int[] mappings)
          Returns a String that describes the current location of the stickers.
static java.lang.String toNormalizedStickersString(Cube cube)
          Returns a String that describes the current location of the stickers.
static java.lang.String toPermutationString(Cube cube)
           
static java.lang.String toPermutationString(Cube cube, Notation notation)
           
static java.lang.String toSidePermutationString(Cube cube)
           
static java.lang.String toSidePermutationString(Cube cube, Notation notation)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static Cube create(int layerCount)
Creates a cube with the specified layer count.


getOrder

public static int getOrder(Cube cube)
Returns a number that describes the order of the permutation of the supplied cube.

The order says how many times the permutation has to be applied to the cube to get the initial state.

Parameters:
cube - A cube
Returns:
the order of the permutation of the cube

getVisibleOrder

public static int getVisibleOrder(Cube cube)
Returns a number that describes the order of the permutation of the supplied cube, assuming that all stickers only have a solid color, and that all stickers on the same face have the same color.

On a cube with such stickers, we can not visually determine the orientation of its side parts, and we can not visually determine a permutation of side parts of which all side parts are on the same face of the cube.

The order says how many times the permutation has to be applied to the cube to get the initial state.

Parameters:
cube - A cube
Returns:
the order of the permutation of the cube

toNormalizedStickersString

public static java.lang.String toNormalizedStickersString(Cube cube)
Returns a String that describes the current location of the stickers. Ignores the rotation of the cube.


toMappedStickersString

public static java.lang.String toMappedStickersString(Cube cube,
                                                      int[] mappings)
Returns a String that describes the current location of the stickers. Ignores the rotation of the cube.


getMappedStickers

public static int[][] getMappedStickers(Cube cube,
                                        int[] mappings)
Returns the stickers reflecting the current permutation of the cube.

Parameters:
mappings - An array with sticker mappings. It must have the same structure as described for method setStickers().
Returns:
Array of stickers: int[6][9]. Same structure as in method setStickers().

getMappedStickers

public static int[][] getMappedStickers(Cube cube,
                                        int[][] mappings)
Returns the stickers reflecting the current permutation of the cube.

Parameters:
mappings - An array with sticker mappings. It must have the same structure as described for method setStickers().
Returns:
Array of stickers: int[6][9]. Same structure as in method setStickers().

getFaceOfSticker

public static int getFaceOfSticker(CubeAttributes attr,
                                   int stickerIndex)

toPermutationString

public static java.lang.String toPermutationString(Cube cube)

toPermutationString

public static java.lang.String toPermutationString(Cube cube,
                                                   Notation notation)

toCornerPermutationString

public static java.lang.String toCornerPermutationString(Cube cube,
                                                         Notation notation)

toCornerPermutationString

public static java.lang.String toCornerPermutationString(Cube cube)

toEdgePermutationString

public static java.lang.String toEdgePermutationString(Cube cube,
                                                       Notation notation)

toEdgePermutationString

public static java.lang.String toEdgePermutationString(Cube cube)

toSidePermutationString

public static java.lang.String toSidePermutationString(Cube cube,
                                                       Notation notation)

toSidePermutationString

public static java.lang.String toSidePermutationString(Cube cube)

setToStickers

public static void setToStickers(Cube cube,
                                 int[] stickers)
Sets the cube to the specified stickers.


(c) Werner Randelshofer.
All rights reserved.