Project

General

Profile

Download (21.7 KB) Statistics
| Branch: | Revision:

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyMinx.java @ 61aa85e4

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.objectlib.objects;
21

    
22
import static org.distorted.objectlib.main.Movement.TYPE_SPLIT_EDGE;
23
import static org.distorted.objectlib.main.Movement12.C2;
24
import static org.distorted.objectlib.main.Movement12.LEN;
25
import static org.distorted.objectlib.main.Movement12.SIN54;
26

    
27
import android.content.res.Resources;
28

    
29
import org.distorted.library.main.DistortedEffects;
30
import org.distorted.library.main.DistortedTexture;
31
import org.distorted.library.mesh.MeshSquare;
32
import org.distorted.library.type.Static3D;
33
import org.distorted.library.type.Static4D;
34
import org.distorted.objectlib.main.Movement;
35
import org.distorted.objectlib.main.Movement12;
36
import org.distorted.objectlib.main.ObjectList;
37
import org.distorted.objectlib.main.ObjectSticker;
38
import org.distorted.objectlib.main.ScrambleState;
39
import org.distorted.objectlib.main.Twisty12;
40

    
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42

    
43
abstract class TwistyMinx extends Twisty12
44
{
45
  static final int NUM_CORNERS = 20;
46
  static final int NUM_CENTERS = 12;
47
  static final int NUM_EDGES   = 30;
48

    
49
  static final float SIN18    = (SQ5-1)/4;
50
  static final float COS18    = (float)(0.25f*Math.sqrt(10.0f+2.0f*SQ5));
51
  static final float COS_HALFD= (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
52
  static final float SIN_HALFD= (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
53

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

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

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

    
98
///////////////////////////////////////////////////////////////////////////////////////////////////
99

    
100
  TwistyMinx(int numLayers, int realSize, Static4D quat, DistortedTexture texture, MeshSquare mesh,
101
             DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
102
    {
103
    super(numLayers, realSize, quat, texture, mesh, effects, moves, res, scrWidth);
104
    }
105

    
106
///////////////////////////////////////////////////////////////////////////////////////////////////
107

    
108
  protected ScrambleState[] getScrambleStates()
109
    {
110
    if( mStates==null )
111
      {
112
      int numLayers = getNumLayers();
113
      initializeScrambleStates(numLayers);
114
      }
115

    
116
    return mStates;
117
    }
118

    
119
///////////////////////////////////////////////////////////////////////////////////////////////////
120

    
121
  void initializeCornerV()
122
    {
123
    mBasicCornerV = new Static4D[3];
124
    mCurrCornerV  = new Static4D[3];
125

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

    
131
///////////////////////////////////////////////////////////////////////////////////////////////////
132
// the five vertices that form a given face. Order: the same as colors of the faces in TwistyMinx.
133

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

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

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

    
196
///////////////////////////////////////////////////////////////////////////////////////////////////
197

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

    
213
///////////////////////////////////////////////////////////////////////////////////////////////////
214

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

    
242
///////////////////////////////////////////////////////////////////////////////////////////////////
243

    
244
  void initializeQuats()
245
    {
246
    mQuats = new Static4D[]
247
         {
248
         new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),  //0
249
         new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
250
         new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
251
         new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
252

    
253
         new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),  //4
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
         new Static4D( -0.5f,  0.5f, -0.5f,  0.5f ),
259
         new Static4D( -0.5f, -0.5f,  0.5f,  0.5f ),
260
         new Static4D( -0.5f, -0.5f, -0.5f,  0.5f ),
261

    
262
         new Static4D(  0.5f, SIN54, SIN18,  0.0f ), // 12
263
         new Static4D(  0.5f, SIN54,-SIN18,  0.0f ),
264
         new Static4D(  0.5f,-SIN54, SIN18,  0.0f ),
265
         new Static4D(  0.5f,-SIN54,-SIN18,  0.0f ),
266
         new Static4D( SIN18,  0.5f, SIN54,  0.0f ),
267
         new Static4D( SIN18,  0.5f,-SIN54,  0.0f ),
268
         new Static4D(-SIN18,  0.5f, SIN54,  0.0f ),
269
         new Static4D(-SIN18,  0.5f,-SIN54,  0.0f ),
270
         new Static4D( SIN54, SIN18,  0.5f,  0.0f ),
271
         new Static4D( SIN54,-SIN18,  0.5f,  0.0f ),
272
         new Static4D(-SIN54, SIN18,  0.5f,  0.0f ),
273
         new Static4D(-SIN54,-SIN18,  0.5f,  0.0f ),
274

    
275
         new Static4D(  0.0f, SIN18, SIN54,  0.5f ), //24
276
         new Static4D(  0.0f, SIN18,-SIN54,  0.5f ),
277
         new Static4D(  0.0f,-SIN18, SIN54,  0.5f ),
278
         new Static4D(  0.0f,-SIN18,-SIN54,  0.5f ),
279
         new Static4D( SIN18, SIN54,  0.0f,  0.5f ),
280
         new Static4D( SIN18,-SIN54,  0.0f,  0.5f ),
281
         new Static4D(-SIN18, SIN54,  0.0f,  0.5f ),
282
         new Static4D(-SIN18,-SIN54,  0.0f,  0.5f ),
283
         new Static4D( SIN54,  0.0f, SIN18,  0.5f ),
284
         new Static4D( SIN54,  0.0f,-SIN18,  0.5f ),
285
         new Static4D(-SIN54,  0.0f, SIN18,  0.5f ),
286
         new Static4D(-SIN54,  0.0f,-SIN18,  0.5f ),
287

    
288
         new Static4D(  0.0f, SIN54,  0.5f, SIN18 ), //36
289
         new Static4D(  0.0f, SIN54, -0.5f, SIN18 ),
290
         new Static4D(  0.0f,-SIN54,  0.5f, SIN18 ),
291
         new Static4D(  0.0f,-SIN54, -0.5f, SIN18 ),
292
         new Static4D(  0.5f,  0.0f, SIN54, SIN18 ),
293
         new Static4D(  0.5f,  0.0f,-SIN54, SIN18 ),
294
         new Static4D( -0.5f,  0.0f, SIN54, SIN18 ),
295
         new Static4D( -0.5f,  0.0f,-SIN54, SIN18 ),
296
         new Static4D( SIN54,  0.5f,  0.0f, SIN18 ),
297
         new Static4D( SIN54, -0.5f,  0.0f, SIN18 ),
298
         new Static4D(-SIN54,  0.5f,  0.0f, SIN18 ),
299
         new Static4D(-SIN54, -0.5f,  0.0f, SIN18 ),
300

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

    
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317
// Coordinates of all 20 corners of a Minx
318

    
319
  void initializeCorners()
320
    {
321
    float cA = 1.5f;
322
    float cB = 3*C2;
323
    float cC = 3*SIN54;
324

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

    
350
///////////////////////////////////////////////////////////////////////////////////////////////////
351

    
352
  void initializeCenterCoords()
353
    {
354
    if( mCorners==null ) initializeCorners();
355
    if( mCenterMap==null ) initializeCenterMap();
356

    
357
    mCenterCoords = new float[NUM_CENTERS][3];
358

    
359
    for(int center=0; center<NUM_CENTERS; center++)
360
      {
361
      int[] map = mCenterMap[center];
362

    
363
      float x = mCorners[map[0]][0] +
364
                mCorners[map[1]][0] +
365
                mCorners[map[2]][0] +
366
                mCorners[map[3]][0] +
367
                mCorners[map[4]][0] ;
368

    
369
      float y = mCorners[map[0]][1] +
370
                mCorners[map[1]][1] +
371
                mCorners[map[2]][1] +
372
                mCorners[map[3]][1] +
373
                mCorners[map[4]][1] ;
374

    
375
      float z = mCorners[map[0]][2] +
376
                mCorners[map[1]][2] +
377
                mCorners[map[2]][2] +
378
                mCorners[map[3]][2] +
379
                mCorners[map[4]][2] ;
380

    
381
      mCenterCoords[center][0] = x/5;
382
      mCenterCoords[center][1] = y/5;
383
      mCenterCoords[center][2] = z/5;
384
      }
385
    }
386

    
387
///////////////////////////////////////////////////////////////////////////////////////////////////
388

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

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

    
410
    return ret;
411
    }
412

    
413
///////////////////////////////////////////////////////////////////////////////////////////////////
414

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

    
420
    for(int i=0; i<rows; i++)
421
      {
422
      int lay = rows+i+1;
423

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

    
438
    return ret;
439
    }
440

    
441
///////////////////////////////////////////////////////////////////////////////////////////////////
442

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

    
449
    for(int i=0; i<rows; i++)
450
      {
451
      int ind = i<half? index : index+1;
452
      int lay = i<half? i : i+1;
453

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

    
468
    return ret;
469
    }
470

    
471
///////////////////////////////////////////////////////////////////////////////////////////////////
472

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

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

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

    
513
///////////////////////////////////////////////////////////////////////////////////////////////////
514

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

    
523
///////////////////////////////////////////////////////////////////////////////////////////////////
524

    
525
  protected Static4D[] getQuats()
526
    {
527
    if( mQuats==null ) initializeQuats();
528
    return mQuats;
529
    }
530
///////////////////////////////////////////////////////////////////////////////////////////////////
531

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

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

    
564
    return mCuts;
565
    }
566

    
567
///////////////////////////////////////////////////////////////////////////////////////////////////
568

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

    
582
///////////////////////////////////////////////////////////////////////////////////////////////////
583

    
584
  protected int getSolvedFunctionIndex()
585
    {
586
    return 0;
587
    }
588

    
589
///////////////////////////////////////////////////////////////////////////////////////////////////
590

    
591
  protected int getNumCubitFaces()
592
    {
593
    return 6;
594
    }
595

    
596
///////////////////////////////////////////////////////////////////////////////////////////////////
597
// PUBLIC API
598

    
599
  public Static3D[] getRotationAxis()
600
    {
601
    return ROT_AXIS;
602
    }
603

    
604
///////////////////////////////////////////////////////////////////////////////////////////////////
605

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

    
618
///////////////////////////////////////////////////////////////////////////////////////////////////
619

    
620
  public int[] getBasicAngle()
621
    {
622
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 5,5,5,5,5,5 };
623
    return mBasicAngle;
624
    }
625
}
(16-16/25)