Modifier and Type | Class and Description |
---|---|
class |
Cube.Face
This class represents a face of the Rubik's cube
An object of this class has an initial orientation which is final, a dynamic orientation which can change every transition, and a matrix of colors represent the colors on this face in the initial state. |
Modifier and Type | Field and Description |
---|---|
private Action[] |
actions |
(package private) Colors[] |
COLORS_ORDERERD_BY_HUE |
protected Cube.Face[] |
faces |
private static Orientation[][] |
ORIENTATION_MAT
This is a static orientation matrix that represent the new position of every face
whenever any face is brought to be at the bottom (DOWN orientation). |
Constructor and Description |
---|
Cube()
Constructor of an object of the type Cube.
|
Modifier and Type | Method and Description |
---|---|
private void |
calcAndSetColors(ArrayList<RawColor> allColors)
Place all scanned colors on the cube, fix red/orange corners
and print result to logger
|
private void |
changePosition(FlipMethod cubeFlips,
Direction direction,
Orientation orientation)
Move the face from its current orientation to the bottom (to be the DOWN face).
|
Cube.Face |
getFace(Orientation orientation)
returns the face which is currently in the orientation requested
|
private void |
printCubeColorsToLogger()
Print all cube's colors to logger
|
void |
setColors()
Scan and set the cube colors
|
void |
setColorsManual(Colors[][] up,
Colors[][] down,
Colors[][] front,
Colors[][] back,
Colors[][] left,
Colors[][] right)
Set the colors of every face of the cube manually
|
private void |
setNonWhitesByHue(ArrayList<RawColor> allColors)
Place all non-white colors on the cube according to their
Hue value
|
private void |
setWhitesByDistance(ArrayList<RawColor> allColors)
Place all white colors on the cube according to their
distance from the calibrated white RGB
|
(package private) void |
updateOrientations(Orientation orientation)
Updates the new orientations of the faces after a transition of the cube.
|
static Boolean |
validateCubeSolution()
Validate correct solution for cube
|
protected Cube.Face[] faces
private Action[] actions
private static final Orientation[][] ORIENTATION_MAT
Colors[] COLORS_ORDERERD_BY_HUE
public Cube()
public Cube.Face getFace(Orientation orientation)
void updateOrientations(Orientation orientation)
orientation
- The current orientation of the face we bring to the bottom (to be the DOWN face)private void changePosition(FlipMethod cubeFlips, Direction direction, Orientation orientation)
cubeFlips
- The number of flips the robot should performdirection
- The direction the robot should rotate the cubeorientation
- The orientation of the face that goes to the bottom (to be the DOWN face)public void setColors()
The method is first to scan all of the cube's colors in RGB mode,
and calculate their HSV representation as well as their distance from
the calibrated white RGB.
Second, sort all the colors by their white distance (since white doesn't have
meaningful Hue value), and place them on the cube.
Last, sort all the colors by their Hue value and place them on the cube
according to their Hue value.
private void setWhitesByDistance(ArrayList<RawColor> allColors)
allColors
- All scanned colorssetColors()
private void setNonWhitesByHue(ArrayList<RawColor> allColors)
allColors
- All scanned colorssetColors()
private void calcAndSetColors(ArrayList<RawColor> allColors)
allColors
- All scanned colorsprivate void printCubeColorsToLogger()
public void setColorsManual(Colors[][] up, Colors[][] down, Colors[][] front, Colors[][] back, Colors[][] left, Colors[][] right)
setColorsManual
in interface ICube
up
- A matrix of colors represents the UP facedown
- A matrix of colors represents the DOWN facefront
- A matrix of colors represents the FRONT faceback
- A matrix of colors represents the BACK faceleft
- A matrix of colors represents the LEFT faceright
- A matrix of colors represents the RIGHT facepublic static Boolean validateCubeSolution()