Project

General

Profile

Download (21.5 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / objects / TwistyMinx.java @ 7ee89540

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2020 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.objects;
21

    
22
import static org.distorted.objects.Movement.TYPE_SPLIT_EDGE;
23

    
24
import android.content.res.Resources;
25

    
26
import org.distorted.helpers.ObjectSticker;
27
import org.distorted.helpers.ScrambleState;
28
import org.distorted.library.main.DistortedEffects;
29
import org.distorted.library.main.DistortedTexture;
30
import org.distorted.library.mesh.MeshSquare;
31
import org.distorted.library.type.Static3D;
32
import org.distorted.library.type.Static4D;
33

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

    
36
abstract class TwistyMinx extends Twisty12
37
{
38
  static final int NUM_CORNERS = 20;
39
  static final int NUM_CENTERS = 12;
40
  static final int NUM_EDGES   = 30;
41

    
42
  static final float C2       = (SQ5+3)/4;
43
  static final float LEN      = (float)(Math.sqrt(1.25f+0.5f*SQ5));
44
  static final float SIN54    = (SQ5+1)/4;
45
  static final float COS54    = (float)(Math.sqrt(10-2*SQ5)/4);
46
  static final float SIN18    = (SQ5-1)/4;
47
  static final float COS18    = (float)(0.25f*Math.sqrt(10.0f+2.0f*SQ5));
48
  static final float COS_HALFD= (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
49
  static final float SIN_HALFD= (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
50

    
51
  // the six rotation axis of a Minx. Must be normalized.
52
  static final Static3D[] ROT_AXIS = new Static3D[]
53
         {
54
           new Static3D(    C2/LEN, SIN54/LEN,    0      ),
55
           new Static3D(   -C2/LEN, SIN54/LEN,    0      ),
56
           new Static3D( 0        ,    C2/LEN, SIN54/LEN ),
57
           new Static3D( 0        ,   -C2/LEN, SIN54/LEN ),
58
           new Static3D( SIN54/LEN,    0     ,    C2/LEN ),
59
           new Static3D( SIN54/LEN,    0     ,   -C2/LEN )
60
         };
61

    
62
  private static final int[][][] ENABLED = new int[][][]
63
      {
64
          {{2,3},{3,5},{1,5},{1,4},{2,4}},
65
          {{0,5},{2,5},{2,3},{3,4},{0,4}},
66
          {{2,3},{2,5},{0,5},{0,4},{3,4}},
67
          {{1,5},{3,5},{2,3},{2,4},{1,4}},
68
          {{0,3},{0,4},{4,5},{1,5},{1,3}},
69
          {{1,2},{1,4},{4,5},{0,5},{0,2}},
70
          {{4,5},{1,4},{1,2},{0,2},{0,5}},
71
          {{4,5},{0,4},{0,3},{1,3},{1,5}},
72
          {{0,2},{0,1},{1,3},{3,5},{2,5}},
73
          {{3,4},{2,4},{1,2},{0,1},{0,3}},
74
          {{2,4},{3,4},{0,3},{0,1},{1,2}},
75
          {{1,3},{0,1},{0,2},{2,5},{3,5}},
76
      };
77

    
78
  private ScrambleState[] mStates;
79
  private int[] mBasicAngle;
80
  private int[] mFaceMap;
81
  private float[][] mCuts;
82
  private boolean[][] mLayerRotatable;
83
  private Movement mMovement;
84
  Static4D[] mQuats;
85
  float[][] mCenterCoords;
86
  float[][] mCorners;
87
  int[][] mCornerFaceMap;
88
  int[] mQuatEdgeIndices;
89
  int[] mQuatCornerIndices;
90
  int[][] mEdgeMap;
91
  int[][] mCenterMap;
92
  Static4D[] mBasicCornerV, mCurrCornerV;
93
  ObjectSticker[] mStickers;
94

    
95
///////////////////////////////////////////////////////////////////////////////////////////////////
96

    
97
  TwistyMinx(int numLayers, int realSize, Static4D quat, DistortedTexture texture, MeshSquare mesh,
98
             DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth)
99
    {
100
    super(numLayers, realSize, quat, texture, mesh, effects, moves, obj, res, scrWidth);
101
    }
102

    
103
///////////////////////////////////////////////////////////////////////////////////////////////////
104

    
105
  ScrambleState[] getScrambleStates()
106
    {
107
    if( mStates==null )
108
      {
109
      int numLayers = getNumLayers();
110
      initializeScrambleStates(numLayers);
111
      }
112

    
113
    return mStates;
114
    }
115

    
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117

    
118
  void initializeCornerV()
119
    {
120
    mBasicCornerV = new Static4D[3];
121
    mCurrCornerV  = new Static4D[3];
122

    
123
    mBasicCornerV[0] = new Static4D( (SQ5+1)*0.375f, (SQ5-1)*0.375f, -0.750f, 0.0f );
124
    mBasicCornerV[1] = new Static4D(-(SQ5+1)*0.375f, (SQ5-1)*0.375f, -0.750f, 0.0f );
125
    mBasicCornerV[2] = new Static4D(              0,        -1.500f,    0.0f, 0.0f );
126
    }
127

    
128
///////////////////////////////////////////////////////////////////////////////////////////////////
129
// the five vertices that form a given face. Order: the same as colors of the faces in TwistyMinx.
130

    
131
  void initializeCenterMap()
132
    {
133
    mCenterMap = new int[][]
134
         {
135
           { 0, 12,  4, 14,  2},
136
           { 0,  2, 18,  6, 16},
137
           { 6, 18, 11, 19,  7},
138
           { 3, 15,  9, 11, 19},
139
           { 4,  5, 15,  9, 14},
140
           { 1, 13,  5, 15,  3},
141
           { 1,  3, 19,  7, 17},
142
           {10, 16,  6,  7, 17},
143
           { 0, 12,  8, 10, 16},
144
           { 8, 13,  5,  4, 12},
145
           { 1, 13,  8, 10, 17},
146
           { 2, 14,  9, 11, 18},
147
         };
148
    }
149

    
150
///////////////////////////////////////////////////////////////////////////////////////////////////
151
// the quadruple ( corner1, corner2, face1, face2 ) defining an edge.
152
// In fact the 2 corners already define it, the faces only provide easy
153
// way to get to know the colors. Order: arbitrary. Face1 arbitrarily on
154
// the 'left' or right of vector corner1 --> corner2, according to Quat.
155

    
156
  void initializeEdgeMap()
157
    {
158
    mEdgeMap = new int[][]
159
         {
160
           {  0, 12,  0,  8}, //0
161
           { 12,  4,  0,  9},
162
           {  4, 14,  0,  4},
163
           { 14,  2,  0, 11},
164
           {  2,  0,  0,  1},
165
           { 14,  9, 11,  4}, //5
166
           {  9, 11, 11,  3},
167
           { 11, 18, 11,  2},
168
           { 18,  2, 11,  1},
169
           { 18,  6,  1,  2},
170
           {  6, 16,  1,  7}, //10
171
           { 16,  0,  1,  8},
172
           { 16, 10,  8,  7},
173
           { 10,  8,  8, 10},
174
           {  8, 12,  8,  9},
175
           {  8, 13,  9, 10}, //15
176
           { 13,  5,  9,  5},
177
           {  5,  4,  9,  4},
178
           {  5, 15,  4,  5},
179
           { 15,  9,  4,  3},
180
           { 11, 19,  2,  3}, //20
181
           { 19,  7,  2,  6},
182
           {  7,  6,  2,  7},
183
           {  7, 17,  7,  6},
184
           { 17, 10,  7, 10},
185
           { 17,  1, 10,  6}, //25
186
           {  1,  3,  5,  6},
187
           {  3, 19,  3,  6},
188
           {  1, 13, 10,  5},
189
           {  3, 15,  5,  3},
190
         };
191
    }
192

    
193
///////////////////////////////////////////////////////////////////////////////////////////////////
194

    
195
  void initializeQuatIndices()
196
    {
197
    mQuatEdgeIndices = new int[]
198
      {
199
        56, 40, 43, 59,  0, 19,  9, 54, 58, 49,
200
        48, 24, 52,  4, 16, 32, 20, 11, 21, 35,
201
        37, 30,  8, 28, 36, 44,  1, 46, 12, 47
202
      };
203
    mQuatCornerIndices = new int[]
204
      {
205
         0,  2,  3,  1, 40, 31, 41, 30, 39, 35,
206
        36, 34, 56, 32, 43, 21, 48, 28, 42, 23
207
      };
208
    }
209

    
210
///////////////////////////////////////////////////////////////////////////////////////////////////
211

    
212
  void initializeCornerFaceMap()
213
    {
214
    mCornerFaceMap = new int[][]
215
         {
216
           {  0, 1, 8 },
217
           {  6, 5,10 },
218
           {  1, 0,11 },
219
           {  5, 6, 3 },
220
           {  0, 9, 4 },
221
           {  5, 4, 9 },
222
           {  7, 1, 2 },
223
           {  2, 6, 7 },
224
           { 10, 9, 8 },
225
           {  4, 3,11 },
226
           {  7,10, 8 },
227
           {  3, 2,11 },
228
           {  0, 8, 9 },
229
           {  9,10, 5 },
230
           {  0, 4,11 },
231
           {  4, 5, 3 },
232
           {  1, 7, 8 },
233
           {  7, 6,10 },
234
           {  2, 1,11 },
235
           {  6, 2, 3 },
236
         };
237
    }
238

    
239
///////////////////////////////////////////////////////////////////////////////////////////////////
240

    
241
  void initializeQuats()
242
    {
243
    mQuats = new Static4D[]
244
         {
245
         new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),  //0
246
         new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
247
         new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
248
         new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
249

    
250
         new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),  //4
251
         new Static4D(  0.5f,  0.5f, -0.5f,  0.5f ),
252
         new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
253
         new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
254
         new Static4D( -0.5f,  0.5f,  0.5f,  0.5f ),
255
         new Static4D( -0.5f,  0.5f, -0.5f,  0.5f ),
256
         new Static4D( -0.5f, -0.5f,  0.5f,  0.5f ),
257
         new Static4D( -0.5f, -0.5f, -0.5f,  0.5f ),
258

    
259
         new Static4D(  0.5f, SIN54, SIN18,  0.0f ), // 12
260
         new Static4D(  0.5f, SIN54,-SIN18,  0.0f ),
261
         new Static4D(  0.5f,-SIN54, SIN18,  0.0f ),
262
         new Static4D(  0.5f,-SIN54,-SIN18,  0.0f ),
263
         new Static4D( SIN18,  0.5f, SIN54,  0.0f ),
264
         new Static4D( SIN18,  0.5f,-SIN54,  0.0f ),
265
         new Static4D(-SIN18,  0.5f, SIN54,  0.0f ),
266
         new Static4D(-SIN18,  0.5f,-SIN54,  0.0f ),
267
         new Static4D( SIN54, SIN18,  0.5f,  0.0f ),
268
         new Static4D( SIN54,-SIN18,  0.5f,  0.0f ),
269
         new Static4D(-SIN54, SIN18,  0.5f,  0.0f ),
270
         new Static4D(-SIN54,-SIN18,  0.5f,  0.0f ),
271

    
272
         new Static4D(  0.0f, SIN18, SIN54,  0.5f ), //24
273
         new Static4D(  0.0f, SIN18,-SIN54,  0.5f ),
274
         new Static4D(  0.0f,-SIN18, SIN54,  0.5f ),
275
         new Static4D(  0.0f,-SIN18,-SIN54,  0.5f ),
276
         new Static4D( SIN18, SIN54,  0.0f,  0.5f ),
277
         new Static4D( SIN18,-SIN54,  0.0f,  0.5f ),
278
         new Static4D(-SIN18, SIN54,  0.0f,  0.5f ),
279
         new Static4D(-SIN18,-SIN54,  0.0f,  0.5f ),
280
         new Static4D( SIN54,  0.0f, SIN18,  0.5f ),
281
         new Static4D( SIN54,  0.0f,-SIN18,  0.5f ),
282
         new Static4D(-SIN54,  0.0f, SIN18,  0.5f ),
283
         new Static4D(-SIN54,  0.0f,-SIN18,  0.5f ),
284

    
285
         new Static4D(  0.0f, SIN54,  0.5f, SIN18 ), //36
286
         new Static4D(  0.0f, SIN54, -0.5f, SIN18 ),
287
         new Static4D(  0.0f,-SIN54,  0.5f, SIN18 ),
288
         new Static4D(  0.0f,-SIN54, -0.5f, SIN18 ),
289
         new Static4D(  0.5f,  0.0f, SIN54, SIN18 ),
290
         new Static4D(  0.5f,  0.0f,-SIN54, SIN18 ),
291
         new Static4D( -0.5f,  0.0f, SIN54, SIN18 ),
292
         new Static4D( -0.5f,  0.0f,-SIN54, SIN18 ),
293
         new Static4D( SIN54,  0.5f,  0.0f, SIN18 ),
294
         new Static4D( SIN54, -0.5f,  0.0f, SIN18 ),
295
         new Static4D(-SIN54,  0.5f,  0.0f, SIN18 ),
296
         new Static4D(-SIN54, -0.5f,  0.0f, SIN18 ),
297

    
298
         new Static4D(  0.0f,  0.5f, SIN18, SIN54 ), //48
299
         new Static4D(  0.0f,  0.5f,-SIN18, SIN54 ),
300
         new Static4D(  0.0f, -0.5f, SIN18, SIN54 ),
301
         new Static4D(  0.0f, -0.5f,-SIN18, SIN54 ),
302
         new Static4D(  0.5f, SIN18,  0.0f, SIN54 ),
303
         new Static4D(  0.5f,-SIN18,  0.0f, SIN54 ),
304
         new Static4D( -0.5f, SIN18,  0.0f, SIN54 ),
305
         new Static4D( -0.5f,-SIN18,  0.0f, SIN54 ),
306
         new Static4D( SIN18,  0.0f,  0.5f, SIN54 ),
307
         new Static4D( SIN18,  0.0f, -0.5f, SIN54 ),
308
         new Static4D(-SIN18,  0.0f,  0.5f, SIN54 ),
309
         new Static4D(-SIN18,  0.0f, -0.5f, SIN54 ),
310
         };
311
    }
312

    
313
///////////////////////////////////////////////////////////////////////////////////////////////////
314
// Coordinates of all 20 corners of a Minx
315

    
316
  void initializeCorners()
317
    {
318
    float cA = 1.5f;
319
    float cB = 3*C2;
320
    float cC = 3*SIN54;
321

    
322
    mCorners = new float[][]
323
         {
324
             {  0, cA, cB},
325
             {  0, cA,-cB},
326
             {  0,-cA, cB},
327
             {  0,-cA,-cB},
328
             { cB,  0, cA},
329
             { cB,  0,-cA},
330
             {-cB,  0, cA},
331
             {-cB,  0,-cA},
332
             { cA, cB,  0},
333
             { cA,-cB,  0},
334
             {-cA, cB,  0},
335
             {-cA,-cB,  0},
336
             { cC, cC, cC},
337
             { cC, cC,-cC},
338
             { cC,-cC, cC},
339
             { cC,-cC,-cC},
340
             {-cC, cC, cC},
341
             {-cC, cC,-cC},
342
             {-cC,-cC, cC},
343
             {-cC,-cC,-cC},
344
         };
345
    }
346

    
347
///////////////////////////////////////////////////////////////////////////////////////////////////
348

    
349
  void initializeCenterCoords()
350
    {
351
    if( mCorners==null ) initializeCorners();
352
    if( mCenterMap==null ) initializeCenterMap();
353

    
354
    mCenterCoords = new float[NUM_CENTERS][3];
355

    
356
    for(int center=0; center<NUM_CENTERS; center++)
357
      {
358
      int[] map = mCenterMap[center];
359

    
360
      float x = mCorners[map[0]][0] +
361
                mCorners[map[1]][0] +
362
                mCorners[map[2]][0] +
363
                mCorners[map[3]][0] +
364
                mCorners[map[4]][0] ;
365

    
366
      float y = mCorners[map[0]][1] +
367
                mCorners[map[1]][1] +
368
                mCorners[map[2]][1] +
369
                mCorners[map[3]][1] +
370
                mCorners[map[4]][1] ;
371

    
372
      float z = mCorners[map[0]][2] +
373
                mCorners[map[1]][2] +
374
                mCorners[map[2]][2] +
375
                mCorners[map[3]][2] +
376
                mCorners[map[4]][2] ;
377

    
378
      mCenterCoords[center][0] = x/5;
379
      mCenterCoords[center][1] = y/5;
380
      mCenterCoords[center][2] = z/5;
381
      }
382
    }
383

    
384
///////////////////////////////////////////////////////////////////////////////////////////////////
385

    
386
  private int[] generateL(int numLayers, int index)
387
    {
388
    int rows = (numLayers-1)/2;
389
    int[] ret = new int[3*4*rows];
390

    
391
    for(int i=0; i<rows; i++)
392
      {
393
      ret[12*i   ] = i;
394
      ret[12*i+ 1] =-2;
395
      ret[12*i+ 2] = index;
396
      ret[12*i+ 3] = i;
397
      ret[12*i+ 4] =-1;
398
      ret[12*i+ 5] = index;
399
      ret[12*i+ 6] = i;
400
      ret[12*i+ 7] =+1;
401
      ret[12*i+ 8] = index;
402
      ret[12*i+ 9] = i;
403
      ret[12*i+10] =+2;
404
      ret[12*i+11] = index;
405
      }
406

    
407
    return ret;
408
    }
409

    
410
///////////////////////////////////////////////////////////////////////////////////////////////////
411

    
412
  private int[] generateR(int numLayers, int index)
413
    {
414
    int rows = (numLayers-1)/2;
415
    int[] ret = new int[3*4*rows];
416

    
417
    for(int i=0; i<rows; i++)
418
      {
419
      int lay = rows+i+1;
420

    
421
      ret[12*i   ] = lay;
422
      ret[12*i+ 1] =-2;
423
      ret[12*i+ 2] = index;
424
      ret[12*i+ 3] = lay;
425
      ret[12*i+ 4] =-1;
426
      ret[12*i+ 5] = index;
427
      ret[12*i+ 6] = lay;
428
      ret[12*i+ 7] =+1;
429
      ret[12*i+ 8] = index;
430
      ret[12*i+ 9] = lay;
431
      ret[12*i+10] =+2;
432
      ret[12*i+11] = index;
433
      }
434

    
435
    return ret;
436
    }
437

    
438
///////////////////////////////////////////////////////////////////////////////////////////////////
439

    
440
  private int[] generateB(int numLayers, int index)
441
    {
442
    int rows = (numLayers-1);
443
    int half = rows/2;
444
    int[] ret = new int[3*4*rows];
445

    
446
    for(int i=0; i<rows; i++)
447
      {
448
      int ind = i<half? index : index+1;
449
      int lay = i<half? i : i+1;
450

    
451
      ret[12*i   ] = lay;
452
      ret[12*i+ 1] =-2;
453
      ret[12*i+ 2] = ind;
454
      ret[12*i+ 3] = lay;
455
      ret[12*i+ 4] =-1;
456
      ret[12*i+ 5] = ind;
457
      ret[12*i+ 6] = lay;
458
      ret[12*i+ 7] =+1;
459
      ret[12*i+ 8] = ind;
460
      ret[12*i+ 9] = lay;
461
      ret[12*i+10] =+2;
462
      ret[12*i+11] = ind;
463
      }
464

    
465
    return ret;
466
    }
467

    
468
///////////////////////////////////////////////////////////////////////////////////////////////////
469

    
470
  private void initializeScrambleStates(int numLayers)
471
    {
472
    int[] LEFT0 = generateL(numLayers,1);
473
    int[] RIGH0 = generateR(numLayers,2);
474
    int[] LEFT1 = generateL(numLayers,3);
475
    int[] RIGH1 = generateR(numLayers,4);
476
    int[] LEFT2 = generateL(numLayers,5);
477
    int[] RIGH2 = generateR(numLayers,6);
478
    int[] LEFT3 = generateL(numLayers,7);
479
    int[] RIGH3 = generateR(numLayers,8);
480
    int[] LEFT4 = generateL(numLayers,9);
481
    int[] RIGH4 = generateR(numLayers,10);
482
    int[] LEFT5 = generateL(numLayers,11);
483
    int[] RIGH5 = generateR(numLayers,12);
484

    
485
    int[] BOTH1 = generateB(numLayers,1);
486
    int[] BOTH3 = generateB(numLayers,3);
487
    int[] BOTH5 = generateB(numLayers,5);
488
    int[] BOTH7 = generateB(numLayers,7);
489
    int[] BOTH9 = generateB(numLayers,9);
490
    int[] BOTH11= generateB(numLayers,11);
491

    
492
    mStates = new ScrambleState[]
493
      {
494
      new ScrambleState( new int[][] { BOTH1,BOTH3,BOTH5,BOTH7,BOTH9,BOTH11 } ), // beg
495
      new ScrambleState( new int[][] { {}   ,RIGH1,LEFT2,RIGH3,LEFT4,LEFT5  } ), // 0L
496
      new ScrambleState( new int[][] { {}   ,LEFT1,RIGH2,LEFT3,RIGH4,RIGH5  } ), // 0R
497
      new ScrambleState( new int[][] { RIGH0,{}   ,LEFT2,RIGH3,RIGH4,RIGH5  } ), // 1L
498
      new ScrambleState( new int[][] { LEFT0,{}   ,RIGH2,LEFT3,LEFT4,LEFT5  } ), // 1R
499
      new ScrambleState( new int[][] { LEFT0,LEFT1,{}   ,RIGH3,LEFT4,RIGH5  } ), // 2L
500
      new ScrambleState( new int[][] { RIGH0,RIGH1,{}   ,LEFT3,RIGH4,LEFT5  } ), // 2R
501
      new ScrambleState( new int[][] { RIGH0,RIGH1,RIGH2,{}   ,LEFT4,RIGH5  } ), // 3L
502
      new ScrambleState( new int[][] { LEFT0,LEFT1,LEFT2,{}   ,RIGH4,LEFT5  } ), // 3R
503
      new ScrambleState( new int[][] { LEFT0,RIGH1,LEFT2,LEFT3,{}   ,RIGH5  } ), // 4L
504
      new ScrambleState( new int[][] { RIGH0,LEFT1,RIGH2,RIGH3,{}   ,LEFT5  } ), // 4R
505
      new ScrambleState( new int[][] { LEFT0,RIGH1,RIGH2,RIGH3,RIGH4,{}     } ), // 5L
506
      new ScrambleState( new int[][] { RIGH0,LEFT1,LEFT2,LEFT3,LEFT4,{}     } ), // 5R
507
      };
508
    }
509

    
510
///////////////////////////////////////////////////////////////////////////////////////////////////
511

    
512
  int[] getSolvedQuats(int cubit, int numLayers)
513
    {
514
    if( mQuats==null ) initializeQuats();
515
    if( mFaceMap==null ) mFaceMap = new int[] {8,10,3,7,1,11,9,2,4,0,5,6};
516
    int status = retCubitSolvedStatus(cubit,numLayers);
517
    return status<0 ? null : buildSolvedQuats(Movement12.FACE_AXIS[mFaceMap[status]],mQuats);
518
    }
519

    
520
///////////////////////////////////////////////////////////////////////////////////////////////////
521

    
522
  Static4D[] getQuats()
523
    {
524
    if( mQuats==null ) initializeQuats();
525
    return mQuats;
526
    }
527
///////////////////////////////////////////////////////////////////////////////////////////////////
528

    
529
  float[][] genericGetCuts(int numLayers, float dist)
530
    {
531
    if( mCuts==null )
532
      {
533
      mCuts = new float[6][numLayers-1];
534
      float D = numLayers*Movement12.DIST3D;
535
      float X = 2*D/(2+SIN18);  // height of the 'upper' part of a dodecahedron, i.e. put it on a table,
536
                                // its height is then 2D, it has one 'lower' part of height X, one
537
                                // 'middle' part of height Y and one upper part of height X again.
538
      int num = (numLayers-1)/2;
539
      float G = X*dist/num;     // height of one Layer
540

    
541
      for(int i=0; i<num; i++)
542
        {
543
        float cut = -D + (i+0.85f)*G;  // 0.85? not fully correct; attempt to make it
544
                                       // easier to rotate the outer layers
545
        int j = 2*num-1-i;
546
        mCuts[0][i] = +cut;
547
        mCuts[0][j] = -cut;
548
        mCuts[1][i] = +cut;
549
        mCuts[1][j] = -cut;
550
        mCuts[2][i] = +cut;
551
        mCuts[2][j] = -cut;
552
        mCuts[3][i] = +cut;
553
        mCuts[3][j] = -cut;
554
        mCuts[4][i] = +cut;
555
        mCuts[4][j] = -cut;
556
        mCuts[5][i] = +cut;
557
        mCuts[5][j] = -cut;
558
        }
559
      }
560

    
561
    return mCuts;
562
    }
563

    
564
///////////////////////////////////////////////////////////////////////////////////////////////////
565

    
566
  private void getLayerRotatable(int numLayers)
567
    {
568
    if( mLayerRotatable==null )
569
      {
570
      int numAxis = ROT_AXIS.length;
571
      boolean[] tmp = new boolean[numLayers];
572
      for(int i=0; i<numLayers; i++) tmp[i] = true;
573
      tmp[numLayers/2] = false;
574
      mLayerRotatable = new boolean[numAxis][];
575
      for(int i=0; i<numAxis; i++) mLayerRotatable[i] = tmp;
576
      }
577
    }
578

    
579
///////////////////////////////////////////////////////////////////////////////////////////////////
580

    
581
  int getSolvedFunctionIndex()
582
    {
583
    return 0;
584
    }
585

    
586
///////////////////////////////////////////////////////////////////////////////////////////////////
587

    
588
  int getNumCubitFaces()
589
    {
590
    return 6;
591
    }
592

    
593
///////////////////////////////////////////////////////////////////////////////////////////////////
594
// PUBLIC API
595

    
596
  public Static3D[] getRotationAxis()
597
    {
598
    return ROT_AXIS;
599
    }
600

    
601
///////////////////////////////////////////////////////////////////////////////////////////////////
602

    
603
  public Movement getMovement()
604
    {
605
    if( mMovement==null )
606
      {
607
      int numLayers = getNumLayers();
608
      if( mCuts==null ) getCuts(numLayers);
609
      getLayerRotatable(numLayers);
610
      mMovement = new Movement12(ROT_AXIS,mCuts,mLayerRotatable,numLayers,TYPE_SPLIT_EDGE,ENABLED);
611
      }
612
    return mMovement;
613
    }
614

    
615
///////////////////////////////////////////////////////////////////////////////////////////////////
616

    
617
  public int[] getBasicAngle()
618
    {
619
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 5,5,5,5,5,5 };
620
    return mBasicAngle;
621
    }
622
}
(27-27/38)