Project

General

Profile

« Previous | Next » 

Revision 4a5157a1

Added by Leszek Koltunski over 2 years ago

Rotations of a Cuboid - finished.

View differences:

src/main/java/org/distorted/objectlib/objects/TwistyCuboid.java
75 75

  
76 76
  private int[] createEdges(int size, boolean full, int vertex)
77 77
    {
78
    if( size==1 ) return null;
79

  
78 80
    if( full )
79 81
      {
80 82
      int[] ret = new int[9*size];
......
128 130
      int[][] mY = new int[16][];
129 131
      int[][] mZ = new int[16][];
130 132

  
131
      for(int i=1; i<16; i++) mX[i] = createEdges(X,Y==Z,i);
132
      for(int i=1; i<16; i++) mY[i] = createEdges(Y,X==Z,i);
133
      for(int i=1; i<16; i++) mZ[i] = createEdges(Z,X==Y,i);
133
      for(int i=0; i<16; i++)
134
        {
135
        mX[i] = createEdges(X,Y==Z,i);
136
        mY[i] = createEdges(Y,X==Z,i);
137
        mZ[i] = createEdges(Z,X==Y,i);
138
        }
134 139

  
135
      mStates = new ScrambleState[]
140
      if( X>1 && Y>1 && Z>1 )
136 141
        {
137
        new ScrambleState( new int[][] { mX[ 1], mY[ 2], mZ[ 3] } ),  //  0 0
138
        new ScrambleState( new int[][] {   null, mY[ 4], mZ[ 5] } ),  //  1 x
139
        new ScrambleState( new int[][] { mX[ 6],   null, mZ[ 7] } ),  //  2 y
140
        new ScrambleState( new int[][] { mX[ 8], mY[ 9],   null } ),  //  3 z
141
        new ScrambleState( new int[][] { mX[10],   null, mZ[ 7] } ),  //  4 xy
142
        new ScrambleState( new int[][] { mX[11], mY[ 9],   null } ),  //  5 xz
143
        new ScrambleState( new int[][] {   null, mY[12], mZ[ 5] } ),  //  6 yx
144
        new ScrambleState( new int[][] { mX[ 8], mY[13],   null } ),  //  7 yz
145
        new ScrambleState( new int[][] {   null, mY[ 4], mZ[14] } ),  //  8 zx
146
        new ScrambleState( new int[][] { mX[ 6],   null, mZ[15] } ),  //  9 zy
147
        new ScrambleState( new int[][] {   null,   null, mZ[ 5] } ),  // 10 xyx
148
        new ScrambleState( new int[][] {   null, mY[ 4],   null } ),  // 11 xzx
149
        new ScrambleState( new int[][] {   null,   null, mZ[ 7] } ),  // 12 yxy
150
        new ScrambleState( new int[][] { mX[ 6],   null,   null } ),  // 13 yzy
151
        new ScrambleState( new int[][] {   null, mY[ 9],   null } ),  // 14 zxz
152
        new ScrambleState( new int[][] { mX[ 8],   null,   null } ),  // 15 zyz
153
        };
142
        mStates = new ScrambleState[]
143
          {
144
          new ScrambleState( new int[][] { mX[ 1], mY[ 2], mZ[ 3] } ),  //  0 0
145
          new ScrambleState( new int[][] {   null, mY[ 4], mZ[ 5] } ),  //  1 x
146
          new ScrambleState( new int[][] { mX[ 6],   null, mZ[ 7] } ),  //  2 y
147
          new ScrambleState( new int[][] { mX[ 8], mY[ 9],   null } ),  //  3 z
148
          new ScrambleState( new int[][] { mX[10],   null, mZ[ 7] } ),  //  4 xy
149
          new ScrambleState( new int[][] { mX[11], mY[ 9],   null } ),  //  5 xz
150
          new ScrambleState( new int[][] {   null, mY[12], mZ[ 5] } ),  //  6 yx
151
          new ScrambleState( new int[][] { mX[ 8], mY[13],   null } ),  //  7 yz
152
          new ScrambleState( new int[][] {   null, mY[ 4], mZ[14] } ),  //  8 zx
153
          new ScrambleState( new int[][] { mX[ 6],   null, mZ[15] } ),  //  9 zy
154
          new ScrambleState( new int[][] {   null,   null, mZ[ 5] } ),  // 10 xyx
155
          new ScrambleState( new int[][] {   null, mY[ 4],   null } ),  // 11 xzx
156
          new ScrambleState( new int[][] {   null,   null, mZ[ 7] } ),  // 12 yxy
157
          new ScrambleState( new int[][] { mX[ 6],   null,   null } ),  // 13 yzy
158
          new ScrambleState( new int[][] {   null, mY[ 9],   null } ),  // 14 zxz
159
          new ScrambleState( new int[][] { mX[ 8],   null,   null } ),  // 15 zyz
160
          };
161
        }
162
      else if( X==1 && Y==1 && Z==1 )
163
        {
164
        int[] state = new int[] {0,-1,0,0,1,0,0,2,0};
165

  
166
        mStates = new ScrambleState[]
167
          {
168
          new ScrambleState( new int[][] { state, state, state } )
169
          };
170
        }
171
      else
172
        {
173
        mStates = new ScrambleState[]
174
          {
175
          new ScrambleState( new int[][] { mX[ 0], mY[ 0], mZ[ 0] } )
176
          };
177
        }
178

  
154 179
      }
155 180

  
156 181
    return mStates;

Also available in: Unified diff