CubeTwister 2.0alpha141 2011-10-13

ch.randelshofer.rubik
Class Cube6

java.lang.Object
  extended by ch.randelshofer.rubik.AbstractCube
      extended by ch.randelshofer.rubik.Cube6
All Implemented Interfaces:
Cube, java.lang.Cloneable

public class Cube6
extends AbstractCube

Represents the state of a 6-times sliced cube (such as a V-Cube 6) by the location and orientation of its parts.

A V-Cube 6 has 8 corner parts, 48 edge parts, 96 side parts and one center part. The parts divide each face of the cube into 6 x 6 layers.

Corner parts

The following diagram shows the initial orientations and locations of the corner parts:

                         +---+---+---+---+---+---+
                         |4.0|               |2.0|
                         +---+               +---+
                         |                       |
                         +                       +
                         |                       |
                         +           u           +
                         |                       |
                         +                       +
                         |                       |
                         +---+               +---+
                         |6.0|               |0.0|
 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
 |4.1|               |6.2|6.1|               |0.2|0.1|               |2.2|2.1|               |4.2|
 +---+               +---+---+               +---+---+               +---+---+               +---+
 |                       |                       |                       |                       |
 +                       +                       +                       +                       +
 |                       |                       |                       |                       |
 +           l           +           f           +           r           +           b           +
 |                       |                       |                       |                       |
 +                       +                       +                       +                       +
 |                       |                       |                       |                       |
 +---+               +---+---+               +---+---+               +---+---+               +---+
 |5.2|               |7.1|7.2|               |1.1|1.2|               |3.1|3.2|               |5.1|
 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
                         |7.0|               |1.0|
                         +---+               +---+
                         |                       |
                         +                       +
                         |           d           |
                         +                       +
                         |                       |
                         +                       +
                         |                       |
                         +---+               +---+
                         |5.0|               |3.0|
                         +---+---+---+---+---+---+
 

Edge parts

The following diagram shows the initial orientations and locations of the edge parts. The first 12 edges are located near the origins of the x-, y- and z-axis. The second 12 edges are located far from the origin of the x-, y- and z-axis. The third 12 edges are located near the origins of the axes. The fourth 12 edges are again located near the origins of the axes.

                                     X--->
                           +---+---+---+---+---+---+
                           |   |27 |3.1|15 |39 |   |
                           +---+---+---+---+---+---+
                           |30 |               |24 |
                           +---+               +---+  
                           |6.0|               |0.0|
                         Z +---+       u       +---+ Z
                         | |18 |               |12 | |
                         V +---+               +---+ V
                           |42 |               |36 |
                           +---+---+---+---+---+---+
           Z--->           |   |33 |9.1|21 |45 |   |       <---Z                   <---X
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
   |   |30 |18 |6.1|42 |   |   |33 |9.0|21 |45 |   |   |36 |12 |0.1|24 |   |   |39 |15 |3.0|27 |   |
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
   |43 |               |46 |46 |               |37 |37 |               |40 |40 |               |43 |
 ^ +---+               +---+---+               +---+---+               +---+---+               +---+ ^
 | |19 |               |22 |22 |               |13 |13 |               |16 |16 |               |19 | |
 Y +---+       l       +---+---+       f       +---+---+       r       +---+---+       b       +---+ Y
   |7.0|               10.0|10.1               |1.1|1.0|               |4.0|4.1|               |7.1| 
   +---+               +---+---+               +---+---+               +---+---+               +---+  
   |31 |               |34 |34 |               |25 |25 |               |28 |28 |               |31 |
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
   |   |32 |8.1|20 |44 |   |   |35 11.0|23 |47 |   |   |38 |14 |2.1|26 |   |   |41 |17 |5.0|29 |   |
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
                           |   |35 11.1|23 |47 |   |       <---Z                   <---X
                           +---+---+---+---+---+---+
                           |44 |               |38 |
                           +---+               +---+ ^
                           |20 |               |14 | |
                           +---+       d       +---+ Z
                           |8.0|               |2.0| 
                           +---+               +---+  
                           |32 |               |26 |
                           +---+---+---+---+---+---+
                           |   |29 |5.1|17 |41 |   |
                           +---+---+---+---+---+---+
                                    X-->
 

Side parts

The following diagram shows the initial orientation and location of the side parts:

                         +---+---+---+---+---+---+
                         |          .1           |
                         +   +---+---+---+---+   +
                         |   |25 |79 |55 |31 |   |
                         +   +---+---+---+---+   +
                         |   |49 | 1 | 7 |85 |   |
                         + .0+---+---+---+---+.2 +
                         |   |73 |19 |13 |61 |   |
                         +   +---+---+---+---+   +
                         |   |43 |67 |91 |37 |   |
                         +   +---+---+---+---+   +
                         |          .3           |
 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
 |          .0           |          .2           |          .3           |          .1           |
 +   +---+---+---+---+   +   +---+---+---+---+   +   +---+---+---+---+   +   +---+---+---+---+   +
 |   |45 |75 |51 |27 |   |   |32 |86 |62 |38 |   |   |36 |90 |66 |42 |   |   |29 |83 |59 |35 |   |
 +   +---+---+---+---+   +   +---+---+---+---+   +   +---+---+---+---+   +   +---+---+---+---+   +
 |   |69 |21 | 3 |81 |   |   |56 | 8 |14 |92 |   |   |60 |12 |18 |72 |   |   |53 | 5 |11 |89 |   |
 + .3+---+---+---+---+.1 + .1+---+---+---+---+.3 + .2+---+---+---+---+.0 + .0+---+---+---+---+.2 +
 |   |93 |15 | 9 |57 |   |   |80 | 2 |20 |68 |   |   |84 | 6 | 0 |48 |   |   |77 |23 |17 |65 |   |
 +   +---+---+---+---+   +   +---+---+---+---+   +   +---+---+---+---+   +   +---+---+---+---+   +
 |   |39 |63 |87 |33 |   |   |26 |50 |74 |44 |   |   |30 |54 |78 |24 |   |   |47 |71 |95 |41 |   |
 +   +---+---+---+---+   +   +---+---+---+---+   +   +---+---+---+---+   +   +---+---+---+---+   +
 |          .2           |          .0           |          .1           |          .3           |
 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
                         |          .0           |
                         +   +---+---+---+---+   +
                         |   |46 |76 |52 |28 |   |
                         +   +---+---+---+---+   +
                         |   |70 |22 | 4 |82 |   |
                         + .3+---+---+---+---+.1 +
                         |   |94 |16 |10 |58 |   |
                         +   +---+---+---+---+   +
                         |   |40 |64 |88 |34 |   |
                         +   +---+---+---+---+   +
                         |          .2           |
                         +---+---+---+---+---+---+
 

For more information about the location and orientation of the parts see AbstractCube.

Version:
2.0.1 2009-01-25 Fixed EDGE_SWIPE_TABLE.
2.0 2009-01-01 Added support for twisting the cube by swiping over its faces.
1.0 2008-08-13 Created.
Author:
Werner Randelshofer

Nested Class Summary
 
Nested classes/interfaces inherited from class ch.randelshofer.rubik.AbstractCube
AbstractCube.TransformType
 
Field Summary
 
Fields inherited from class ch.randelshofer.rubik.AbstractCube
CENTER_PART, CENTER_TO_SIDE_MAP, CORNER_PART, CORNER_SWIPE_TABLE, CORNER_TO_FACE_MAP, cornerLoc, cornerOrient, EDGE_PART, EDGE_TO_ANGLE_MAP, EDGE_TO_AXIS_MAP, EDGE_TO_FACE_MAP, edgeLoc, edgeOrient, layerCount, NUMBER_OF_CORNER_PARTS, SIDE_PART, sideLoc, sideOrient, transformAngle, transformAxis, transformMask, transformType
 
Constructor Summary
Cube6()
          Creates a new instance.
 
Method Summary
 int getPartLayerMask(int part, int orientation)
          Returns the current layer mask on which the orientation of the part lies.
 int getPartSwipeAngle(int part, int orientation, int swipeDirection)
          Returns the angle on which the orientation of the part can be swiped into the specified direction.
 int getPartSwipeAxis(int part, int orientation, int swipeDirection)
          Returns the axis on which the orientation of the part can be swiped into the specified direction.
 int getPartSwipeLayerMask(int part, int orientation, int swipeDirection)
          Returns the layer mask on which the orientation of the part can be swiped into the specified direction.
 void setToStickers(int[][] stickers)
          Sets the cube to a state where the faces of the parts map to the provided stickers array.
 int[][] toStickers()
          Converts the cube into a stickers array reflecting the current permutation of the cube.
 void transform0(int axis, int layerMask, int angle)
          Transforms the cube and fires a cubeTwisted event.
 
Methods inherited from class ch.randelshofer.rubik.AbstractCube
addCubeListener, clone, equals, fireCubeChanged, fireCubeTwisted, fourCycle, getCornerAt, getCornerCount, getCornerLocation, getCornerLocations, getCornerOrientation, getCornerOrientations, getCubeOrientation, getEdgeAt, getEdgeCount, getEdgeLocation, getEdgeLocations, getEdgeOrientation, getEdgeOrientations, getLayerCount, getPartAngle, getPartAt, getPartAxis, getPartCount, getPartFace, getPartLocation, getPartOrientation, getPartType, getSideAt, getSideCount, getSideLocation, getSideLocations, getSideOrientation, getSideOrientations, getUnsolvedParts, hashCode, isQuiet, isSolved, removeCubeListener, reset, setCorners, setEdges, setQuiet, setSides, setTo, transform, transform, twoCycle
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cube6

public Cube6()
Creates a new instance.

Method Detail

transform0

public void transform0(int axis,
                       int layerMask,
                       int angle)
Description copied from class: AbstractCube
Transforms the cube and fires a cubeTwisted event.

Specified by:
transform0 in class AbstractCube
Parameters:
axis - 0=x, 1=y, 2=z axis.
layerMask - A bitmask specifying the layers to be transformed. The size of the layer mask depends on the value returned by getLayerCount(axis). For a 3x3x3 cube, the layer mask has the following meaning: 7=rotate the whole cube;
1=twist slice near the axis (left, bottom, behind)
2=twist slice in the middle of the axis
4=twist slice far away from the axis (right, top, front)
angle - positive values=clockwise rotation
negative values=counterclockwise rotation
1=90 degrees
2=180 degrees
See Also:
AbstractCube.getLayerCount()

getPartLayerMask

public int getPartLayerMask(int part,
                            int orientation)
Returns the current layer mask on which the orientation of the part lies. Returns 0 if no mask can be determined (the center part).

Specified by:
getPartLayerMask in interface Cube
Specified by:
getPartLayerMask in class AbstractCube
Returns:
2^layer number

toStickers

public int[][] toStickers()
Description copied from interface: Cube
Converts the cube into a stickers array reflecting the current permutation of the cube.

Returns:
Array of stickers: int[6][getLayerCount()*getLayerCount()]. Same structure as in method setStickers().
See Also:
Cube.setToStickers(int[][])

setToStickers

public void setToStickers(int[][] stickers)
Description copied from interface: Cube
Sets the cube to a state where the faces of the parts map to the provided stickers array.

Parameters:
stickers - Sticker array to be reused. The method creates a new array if this parameter is null.

getPartSwipeAxis

public int getPartSwipeAxis(int part,
                            int orientation,
                            int swipeDirection)
Description copied from interface: Cube
Returns the axis on which the orientation of the part can be swiped into the specified direction.

Parameters:
part - The part index.
orientation - The orientation of the part where swiping is performed.
swipeDirection - The direction of the swipe. 0=up,1=right,2=down,4=left.
Returns:
0 for the x-axis, 1 for the y-axis, 2 for the z-axis. -1 if the part lies on none or multiple axis (the center part).

getPartSwipeLayerMask

public int getPartSwipeLayerMask(int part,
                                 int orientation,
                                 int swipeDirection)
Description copied from interface: Cube
Returns the layer mask on which the orientation of the part can be swiped into the specified direction. Returns 0 if no mask can be determined (the center part).

Parameters:
part - The part index.
orientation - The orientation of the part where swiping is performed.
swipeDirection - The direction of the swipe. 0=up,1=right,2=down,4=left.
Returns:
2^layer number

getPartSwipeAngle

public int getPartSwipeAngle(int part,
                             int orientation,
                             int swipeDirection)
Description copied from interface: Cube
Returns the angle on which the orientation of the part can be swiped into the specified direction.

Parameters:
part - The part index.
orientation - The orientation of the part where swiping is performed.
swipeDirection - The direction of the swipe. 0=up,1=right,2=down,4=left.
Returns:
Returns 1 or -1. Returns 0 if the direction can not be determined (the center part).

(c) Werner Randelshofer.
All rights reserved.