Project

General

Profile

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

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyMinx.java @ 55fa6993

1 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
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 59c20632 Leszek Koltunski
import static org.distorted.objectlib.main.Movement.MOVEMENT_DODECAHEDRON;
23 29b82486 Leszek Koltunski
import static org.distorted.objectlib.main.Movement.TYPE_SPLIT_EDGE;
24
import static org.distorted.objectlib.main.Movement12.C2;
25
import static org.distorted.objectlib.main.Movement12.LEN;
26
import static org.distorted.objectlib.main.Movement12.SIN54;
27
28
import android.content.res.Resources;
29
30
import org.distorted.library.main.DistortedEffects;
31
import org.distorted.library.main.DistortedTexture;
32
import org.distorted.library.mesh.MeshSquare;
33
import org.distorted.library.type.Static3D;
34
import org.distorted.library.type.Static4D;
35
import org.distorted.objectlib.main.Movement12;
36 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectSticker;
37
import org.distorted.objectlib.helpers.ScrambleState;
38 29b82486 Leszek Koltunski
import org.distorted.objectlib.main.Twisty12;
39
40
///////////////////////////////////////////////////////////////////////////////////////////////////
41
42
abstract class TwistyMinx extends Twisty12
43
{
44
  static final int NUM_CORNERS = 20;
45
  static final int NUM_CENTERS = 12;
46
  static final int NUM_EDGES   = 30;
47
48
  static final float SIN18    = (SQ5-1)/4;
49
  static final float COS18    = (float)(0.25f*Math.sqrt(10.0f+2.0f*SQ5));
50
  static final float COS_HALFD= (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
51
  static final float SIN_HALFD= (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
52
53
  // the six rotation axis of a Minx. Must be normalized.
54
  static final Static3D[] ROT_AXIS = new Static3D[]
55
         {
56
           new Static3D(    C2/LEN, SIN54/LEN,    0      ),
57
           new Static3D(   -C2/LEN, SIN54/LEN,    0      ),
58
           new Static3D( 0        ,    C2/LEN, SIN54/LEN ),
59
           new Static3D( 0        ,   -C2/LEN, SIN54/LEN ),
60
           new Static3D( SIN54/LEN,    0     ,    C2/LEN ),
61
           new Static3D( SIN54/LEN,    0     ,   -C2/LEN )
62
         };
63
64
  private ScrambleState[] mStates;
65
  private int[] mBasicAngle;
66
  private int[] mFaceMap;
67
  private float[][] mCuts;
68
  Static4D[] mQuats;
69
  float[][] mCenterCoords;
70
  float[][] mCorners;
71
  int[][] mCornerFaceMap;
72
  int[] mQuatEdgeIndices;
73
  int[] mQuatCornerIndices;
74
  int[][] mEdgeMap;
75
  int[][] mCenterMap;
76
  Static4D[] mBasicCornerV, mCurrCornerV;
77
  ObjectSticker[] mStickers;
78
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80
81 a57e6870 Leszek Koltunski
  TwistyMinx(int[] numL, Static4D quat, Static3D move, DistortedTexture texture,
82 e7daa161 Leszek Koltunski
             MeshSquare mesh, DistortedEffects effects, Resources res, int surfaceW, int surfaceH)
83 29b82486 Leszek Koltunski
    {
84 e7daa161 Leszek Koltunski
    super(numL, numL[0], quat, move, texture, mesh, effects, res, surfaceW, surfaceH);
85 29b82486 Leszek Koltunski
    }
86
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88
89 f9a81f52 Leszek Koltunski
  public ScrambleState[] getScrambleStates()
90 29b82486 Leszek Koltunski
    {
91
    if( mStates==null )
92
      {
93 a57e6870 Leszek Koltunski
      int[] numLayers = getNumLayers();
94
      initializeScrambleStates(numLayers[0]);
95 29b82486 Leszek Koltunski
      }
96
97
    return mStates;
98
    }
99
100
///////////////////////////////////////////////////////////////////////////////////////////////////
101
102
  void initializeCornerV()
103
    {
104
    mBasicCornerV = new Static4D[3];
105
    mCurrCornerV  = new Static4D[3];
106
107
    mBasicCornerV[0] = new Static4D( (SQ5+1)*0.375f, (SQ5-1)*0.375f, -0.750f, 0.0f );
108
    mBasicCornerV[1] = new Static4D(-(SQ5+1)*0.375f, (SQ5-1)*0.375f, -0.750f, 0.0f );
109
    mBasicCornerV[2] = new Static4D(              0,        -1.500f,    0.0f, 0.0f );
110
    }
111
112
///////////////////////////////////////////////////////////////////////////////////////////////////
113
// the five vertices that form a given face. Order: the same as colors of the faces in TwistyMinx.
114
115
  void initializeCenterMap()
116
    {
117
    mCenterMap = new int[][]
118
         {
119
           { 0, 12,  4, 14,  2},
120
           { 0,  2, 18,  6, 16},
121
           { 6, 18, 11, 19,  7},
122
           { 3, 15,  9, 11, 19},
123
           { 4,  5, 15,  9, 14},
124
           { 1, 13,  5, 15,  3},
125
           { 1,  3, 19,  7, 17},
126
           {10, 16,  6,  7, 17},
127
           { 0, 12,  8, 10, 16},
128
           { 8, 13,  5,  4, 12},
129
           { 1, 13,  8, 10, 17},
130
           { 2, 14,  9, 11, 18},
131
         };
132
    }
133
134
///////////////////////////////////////////////////////////////////////////////////////////////////
135
// the quadruple ( corner1, corner2, face1, face2 ) defining an edge.
136
// In fact the 2 corners already define it, the faces only provide easy
137
// way to get to know the colors. Order: arbitrary. Face1 arbitrarily on
138
// the 'left' or right of vector corner1 --> corner2, according to Quat.
139
140
  void initializeEdgeMap()
141
    {
142
    mEdgeMap = new int[][]
143
         {
144
           {  0, 12,  0,  8}, //0
145
           { 12,  4,  0,  9},
146
           {  4, 14,  0,  4},
147
           { 14,  2,  0, 11},
148
           {  2,  0,  0,  1},
149
           { 14,  9, 11,  4}, //5
150
           {  9, 11, 11,  3},
151
           { 11, 18, 11,  2},
152
           { 18,  2, 11,  1},
153
           { 18,  6,  1,  2},
154
           {  6, 16,  1,  7}, //10
155
           { 16,  0,  1,  8},
156
           { 16, 10,  8,  7},
157
           { 10,  8,  8, 10},
158
           {  8, 12,  8,  9},
159
           {  8, 13,  9, 10}, //15
160
           { 13,  5,  9,  5},
161
           {  5,  4,  9,  4},
162
           {  5, 15,  4,  5},
163
           { 15,  9,  4,  3},
164
           { 11, 19,  2,  3}, //20
165
           { 19,  7,  2,  6},
166
           {  7,  6,  2,  7},
167
           {  7, 17,  7,  6},
168
           { 17, 10,  7, 10},
169
           { 17,  1, 10,  6}, //25
170
           {  1,  3,  5,  6},
171
           {  3, 19,  3,  6},
172
           {  1, 13, 10,  5},
173
           {  3, 15,  5,  3},
174
         };
175
    }
176
177
///////////////////////////////////////////////////////////////////////////////////////////////////
178
179
  void initializeQuatIndices()
180
    {
181
    mQuatEdgeIndices = new int[]
182
      {
183
        56, 40, 43, 59,  0, 19,  9, 54, 58, 49,
184
        48, 24, 52,  4, 16, 32, 20, 11, 21, 35,
185
        37, 30,  8, 28, 36, 44,  1, 46, 12, 47
186
      };
187
    mQuatCornerIndices = new int[]
188
      {
189
         0,  2,  3,  1, 40, 31, 41, 30, 39, 35,
190
        36, 34, 56, 32, 43, 21, 48, 28, 42, 23
191
      };
192
    }
193
194
///////////////////////////////////////////////////////////////////////////////////////////////////
195
196
  void initializeCornerFaceMap()
197
    {
198
    mCornerFaceMap = new int[][]
199
         {
200
           {  0, 1, 8 },
201
           {  6, 5,10 },
202
           {  1, 0,11 },
203
           {  5, 6, 3 },
204
           {  0, 9, 4 },
205
           {  5, 4, 9 },
206
           {  7, 1, 2 },
207
           {  2, 6, 7 },
208
           { 10, 9, 8 },
209
           {  4, 3,11 },
210
           {  7,10, 8 },
211
           {  3, 2,11 },
212
           {  0, 8, 9 },
213
           {  9,10, 5 },
214
           {  0, 4,11 },
215
           {  4, 5, 3 },
216
           {  1, 7, 8 },
217
           {  7, 6,10 },
218
           {  2, 1,11 },
219
           {  6, 2, 3 },
220
         };
221
    }
222
223
///////////////////////////////////////////////////////////////////////////////////////////////////
224
225
  void initializeQuats()
226
    {
227
    mQuats = new Static4D[]
228
         {
229
         new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),  //0
230
         new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
231
         new Static4D(  0.0f,  1.0f,  0.0f,  0.0f ),
232
         new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
233
234
         new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),  //4
235
         new Static4D(  0.5f,  0.5f, -0.5f,  0.5f ),
236
         new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
237
         new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
238
         new Static4D( -0.5f,  0.5f,  0.5f,  0.5f ),
239
         new Static4D( -0.5f,  0.5f, -0.5f,  0.5f ),
240
         new Static4D( -0.5f, -0.5f,  0.5f,  0.5f ),
241
         new Static4D( -0.5f, -0.5f, -0.5f,  0.5f ),
242
243
         new Static4D(  0.5f, SIN54, SIN18,  0.0f ), // 12
244
         new Static4D(  0.5f, SIN54,-SIN18,  0.0f ),
245
         new Static4D(  0.5f,-SIN54, SIN18,  0.0f ),
246
         new Static4D(  0.5f,-SIN54,-SIN18,  0.0f ),
247
         new Static4D( SIN18,  0.5f, SIN54,  0.0f ),
248
         new Static4D( SIN18,  0.5f,-SIN54,  0.0f ),
249
         new Static4D(-SIN18,  0.5f, SIN54,  0.0f ),
250
         new Static4D(-SIN18,  0.5f,-SIN54,  0.0f ),
251
         new Static4D( SIN54, SIN18,  0.5f,  0.0f ),
252
         new Static4D( SIN54,-SIN18,  0.5f,  0.0f ),
253
         new Static4D(-SIN54, SIN18,  0.5f,  0.0f ),
254
         new Static4D(-SIN54,-SIN18,  0.5f,  0.0f ),
255
256
         new Static4D(  0.0f, SIN18, SIN54,  0.5f ), //24
257
         new Static4D(  0.0f, SIN18,-SIN54,  0.5f ),
258
         new Static4D(  0.0f,-SIN18, SIN54,  0.5f ),
259
         new Static4D(  0.0f,-SIN18,-SIN54,  0.5f ),
260
         new Static4D( SIN18, SIN54,  0.0f,  0.5f ),
261
         new Static4D( SIN18,-SIN54,  0.0f,  0.5f ),
262
         new Static4D(-SIN18, SIN54,  0.0f,  0.5f ),
263
         new Static4D(-SIN18,-SIN54,  0.0f,  0.5f ),
264
         new Static4D( SIN54,  0.0f, SIN18,  0.5f ),
265
         new Static4D( SIN54,  0.0f,-SIN18,  0.5f ),
266
         new Static4D(-SIN54,  0.0f, SIN18,  0.5f ),
267
         new Static4D(-SIN54,  0.0f,-SIN18,  0.5f ),
268
269
         new Static4D(  0.0f, SIN54,  0.5f, SIN18 ), //36
270
         new Static4D(  0.0f, SIN54, -0.5f, SIN18 ),
271
         new Static4D(  0.0f,-SIN54,  0.5f, SIN18 ),
272
         new Static4D(  0.0f,-SIN54, -0.5f, SIN18 ),
273
         new Static4D(  0.5f,  0.0f, SIN54, SIN18 ),
274
         new Static4D(  0.5f,  0.0f,-SIN54, SIN18 ),
275
         new Static4D( -0.5f,  0.0f, SIN54, SIN18 ),
276
         new Static4D( -0.5f,  0.0f,-SIN54, SIN18 ),
277
         new Static4D( SIN54,  0.5f,  0.0f, SIN18 ),
278
         new Static4D( SIN54, -0.5f,  0.0f, SIN18 ),
279
         new Static4D(-SIN54,  0.5f,  0.0f, SIN18 ),
280
         new Static4D(-SIN54, -0.5f,  0.0f, SIN18 ),
281
282
         new Static4D(  0.0f,  0.5f, SIN18, SIN54 ), //48
283
         new Static4D(  0.0f,  0.5f,-SIN18, SIN54 ),
284
         new Static4D(  0.0f, -0.5f, SIN18, SIN54 ),
285
         new Static4D(  0.0f, -0.5f,-SIN18, SIN54 ),
286
         new Static4D(  0.5f, SIN18,  0.0f, SIN54 ),
287
         new Static4D(  0.5f,-SIN18,  0.0f, SIN54 ),
288
         new Static4D( -0.5f, SIN18,  0.0f, SIN54 ),
289
         new Static4D( -0.5f,-SIN18,  0.0f, SIN54 ),
290
         new Static4D( SIN18,  0.0f,  0.5f, SIN54 ),
291
         new Static4D( SIN18,  0.0f, -0.5f, SIN54 ),
292
         new Static4D(-SIN18,  0.0f,  0.5f, SIN54 ),
293
         new Static4D(-SIN18,  0.0f, -0.5f, SIN54 ),
294
         };
295
    }
296
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298
// Coordinates of all 20 corners of a Minx
299
300
  void initializeCorners()
301
    {
302
    float cA = 1.5f;
303
    float cB = 3*C2;
304
    float cC = 3*SIN54;
305
306
    mCorners = new float[][]
307
         {
308
             {  0, cA, cB},
309
             {  0, cA,-cB},
310
             {  0,-cA, cB},
311
             {  0,-cA,-cB},
312
             { cB,  0, cA},
313
             { cB,  0,-cA},
314
             {-cB,  0, cA},
315
             {-cB,  0,-cA},
316
             { cA, cB,  0},
317
             { cA,-cB,  0},
318
             {-cA, cB,  0},
319
             {-cA,-cB,  0},
320
             { cC, cC, cC},
321
             { cC, cC,-cC},
322
             { cC,-cC, cC},
323
             { cC,-cC,-cC},
324
             {-cC, cC, cC},
325
             {-cC, cC,-cC},
326
             {-cC,-cC, cC},
327
             {-cC,-cC,-cC},
328
         };
329
    }
330
331
///////////////////////////////////////////////////////////////////////////////////////////////////
332
333
  void initializeCenterCoords()
334
    {
335
    if( mCorners==null ) initializeCorners();
336
    if( mCenterMap==null ) initializeCenterMap();
337
338
    mCenterCoords = new float[NUM_CENTERS][3];
339
340
    for(int center=0; center<NUM_CENTERS; center++)
341
      {
342
      int[] map = mCenterMap[center];
343
344
      float x = mCorners[map[0]][0] +
345
                mCorners[map[1]][0] +
346
                mCorners[map[2]][0] +
347
                mCorners[map[3]][0] +
348
                mCorners[map[4]][0] ;
349
350
      float y = mCorners[map[0]][1] +
351
                mCorners[map[1]][1] +
352
                mCorners[map[2]][1] +
353
                mCorners[map[3]][1] +
354
                mCorners[map[4]][1] ;
355
356
      float z = mCorners[map[0]][2] +
357
                mCorners[map[1]][2] +
358
                mCorners[map[2]][2] +
359
                mCorners[map[3]][2] +
360
                mCorners[map[4]][2] ;
361
362
      mCenterCoords[center][0] = x/5;
363
      mCenterCoords[center][1] = y/5;
364
      mCenterCoords[center][2] = z/5;
365
      }
366
    }
367
368
///////////////////////////////////////////////////////////////////////////////////////////////////
369
370
  private int[] generateL(int numLayers, int index)
371
    {
372
    int rows = (numLayers-1)/2;
373
    int[] ret = new int[3*4*rows];
374
375
    for(int i=0; i<rows; i++)
376
      {
377
      ret[12*i   ] = i;
378
      ret[12*i+ 1] =-2;
379
      ret[12*i+ 2] = index;
380
      ret[12*i+ 3] = i;
381
      ret[12*i+ 4] =-1;
382
      ret[12*i+ 5] = index;
383
      ret[12*i+ 6] = i;
384
      ret[12*i+ 7] =+1;
385
      ret[12*i+ 8] = index;
386
      ret[12*i+ 9] = i;
387
      ret[12*i+10] =+2;
388
      ret[12*i+11] = index;
389
      }
390
391
    return ret;
392
    }
393
394
///////////////////////////////////////////////////////////////////////////////////////////////////
395
396
  private int[] generateR(int numLayers, int index)
397
    {
398
    int rows = (numLayers-1)/2;
399
    int[] ret = new int[3*4*rows];
400
401
    for(int i=0; i<rows; i++)
402
      {
403
      int lay = rows+i+1;
404
405
      ret[12*i   ] = lay;
406
      ret[12*i+ 1] =-2;
407
      ret[12*i+ 2] = index;
408
      ret[12*i+ 3] = lay;
409
      ret[12*i+ 4] =-1;
410
      ret[12*i+ 5] = index;
411
      ret[12*i+ 6] = lay;
412
      ret[12*i+ 7] =+1;
413
      ret[12*i+ 8] = index;
414
      ret[12*i+ 9] = lay;
415
      ret[12*i+10] =+2;
416
      ret[12*i+11] = index;
417
      }
418
419
    return ret;
420
    }
421
422
///////////////////////////////////////////////////////////////////////////////////////////////////
423
424
  private int[] generateB(int numLayers, int index)
425
    {
426
    int rows = (numLayers-1);
427
    int half = rows/2;
428
    int[] ret = new int[3*4*rows];
429
430
    for(int i=0; i<rows; i++)
431
      {
432
      int ind = i<half? index : index+1;
433
      int lay = i<half? i : i+1;
434
435
      ret[12*i   ] = lay;
436
      ret[12*i+ 1] =-2;
437
      ret[12*i+ 2] = ind;
438
      ret[12*i+ 3] = lay;
439
      ret[12*i+ 4] =-1;
440
      ret[12*i+ 5] = ind;
441
      ret[12*i+ 6] = lay;
442
      ret[12*i+ 7] =+1;
443
      ret[12*i+ 8] = ind;
444
      ret[12*i+ 9] = lay;
445
      ret[12*i+10] =+2;
446
      ret[12*i+11] = ind;
447
      }
448
449
    return ret;
450
    }
451
452
///////////////////////////////////////////////////////////////////////////////////////////////////
453
454
  private void initializeScrambleStates(int numLayers)
455
    {
456
    int[] LEFT0 = generateL(numLayers,1);
457
    int[] RIGH0 = generateR(numLayers,2);
458
    int[] LEFT1 = generateL(numLayers,3);
459
    int[] RIGH1 = generateR(numLayers,4);
460
    int[] LEFT2 = generateL(numLayers,5);
461
    int[] RIGH2 = generateR(numLayers,6);
462
    int[] LEFT3 = generateL(numLayers,7);
463
    int[] RIGH3 = generateR(numLayers,8);
464
    int[] LEFT4 = generateL(numLayers,9);
465
    int[] RIGH4 = generateR(numLayers,10);
466
    int[] LEFT5 = generateL(numLayers,11);
467
    int[] RIGH5 = generateR(numLayers,12);
468
469
    int[] BOTH1 = generateB(numLayers,1);
470
    int[] BOTH3 = generateB(numLayers,3);
471
    int[] BOTH5 = generateB(numLayers,5);
472
    int[] BOTH7 = generateB(numLayers,7);
473
    int[] BOTH9 = generateB(numLayers,9);
474
    int[] BOTH11= generateB(numLayers,11);
475
476
    mStates = new ScrambleState[]
477
      {
478
      new ScrambleState( new int[][] { BOTH1,BOTH3,BOTH5,BOTH7,BOTH9,BOTH11 } ), // beg
479
      new ScrambleState( new int[][] { {}   ,RIGH1,LEFT2,RIGH3,LEFT4,LEFT5  } ), // 0L
480
      new ScrambleState( new int[][] { {}   ,LEFT1,RIGH2,LEFT3,RIGH4,RIGH5  } ), // 0R
481
      new ScrambleState( new int[][] { RIGH0,{}   ,LEFT2,RIGH3,RIGH4,RIGH5  } ), // 1L
482
      new ScrambleState( new int[][] { LEFT0,{}   ,RIGH2,LEFT3,LEFT4,LEFT5  } ), // 1R
483
      new ScrambleState( new int[][] { LEFT0,LEFT1,{}   ,RIGH3,LEFT4,RIGH5  } ), // 2L
484
      new ScrambleState( new int[][] { RIGH0,RIGH1,{}   ,LEFT3,RIGH4,LEFT5  } ), // 2R
485
      new ScrambleState( new int[][] { RIGH0,RIGH1,RIGH2,{}   ,LEFT4,RIGH5  } ), // 3L
486
      new ScrambleState( new int[][] { LEFT0,LEFT1,LEFT2,{}   ,RIGH4,LEFT5  } ), // 3R
487
      new ScrambleState( new int[][] { LEFT0,RIGH1,LEFT2,LEFT3,{}   ,RIGH5  } ), // 4L
488
      new ScrambleState( new int[][] { RIGH0,LEFT1,RIGH2,RIGH3,{}   ,LEFT5  } ), // 4R
489
      new ScrambleState( new int[][] { LEFT0,RIGH1,RIGH2,RIGH3,RIGH4,{}     } ), // 5L
490
      new ScrambleState( new int[][] { RIGH0,LEFT1,LEFT2,LEFT3,LEFT4,{}     } ), // 5R
491
      };
492
    }
493
494
///////////////////////////////////////////////////////////////////////////////////////////////////
495
496 7b832206 Leszek Koltunski
  public int[] getSolvedQuats(int cubit, int[] numLayers)
497 29b82486 Leszek Koltunski
    {
498
    if( mQuats==null ) initializeQuats();
499 e6b45809 Leszek Koltunski
    if( mFaceMap==null ) mFaceMap = new int[] {8,10,3,7,1,9,11,2,4,0,5,6};
500 29b82486 Leszek Koltunski
    int status = retCubitSolvedStatus(cubit,numLayers);
501
    return status<0 ? null : buildSolvedQuats(Movement12.FACE_AXIS[mFaceMap[status]],mQuats);
502
    }
503
504
///////////////////////////////////////////////////////////////////////////////////////////////////
505
506 1bb09f88 Leszek Koltunski
  public Static4D[] getQuats()
507 29b82486 Leszek Koltunski
    {
508
    if( mQuats==null ) initializeQuats();
509
    return mQuats;
510
    }
511 e6b45809 Leszek Koltunski
512 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
513
514
  float[][] genericGetCuts(int numLayers, float dist)
515
    {
516
    if( mCuts==null )
517
      {
518
      mCuts = new float[6][numLayers-1];
519
      float D = numLayers*Movement12.DIST3D;
520
      float X = 2*D/(2+SIN18);  // height of the 'upper' part of a dodecahedron, i.e. put it on a table,
521
                                // its height is then 2D, it has one 'lower' part of height X, one
522
                                // 'middle' part of height Y and one upper part of height X again.
523
      int num = (numLayers-1)/2;
524
      float G = X*dist/num;     // height of one Layer
525
526
      for(int i=0; i<num; i++)
527
        {
528
        float cut = -D + (i+0.85f)*G;  // 0.85? not fully correct; attempt to make it
529
                                       // easier to rotate the outer layers
530
        int j = 2*num-1-i;
531
        mCuts[0][i] = +cut;
532
        mCuts[0][j] = -cut;
533
        mCuts[1][i] = +cut;
534
        mCuts[1][j] = -cut;
535
        mCuts[2][i] = +cut;
536
        mCuts[2][j] = -cut;
537
        mCuts[3][i] = +cut;
538
        mCuts[3][j] = -cut;
539
        mCuts[4][i] = +cut;
540
        mCuts[4][j] = -cut;
541
        mCuts[5][i] = +cut;
542
        mCuts[5][j] = -cut;
543
        }
544
      }
545
546
    return mCuts;
547
    }
548
549
///////////////////////////////////////////////////////////////////////////////////////////////////
550
551 59c20632 Leszek Koltunski
  public boolean[][] getLayerRotatable(int[] numLayers)
552 29b82486 Leszek Koltunski
    {
553 59c20632 Leszek Koltunski
    int numAxis = ROT_AXIS.length;
554
    boolean[][] layerRotatable = new boolean[numAxis][];
555 a57e6870 Leszek Koltunski
556 59c20632 Leszek Koltunski
    for(int i=0; i<numAxis; i++)
557
      {
558
      layerRotatable[i] = new boolean[numLayers[i]];
559
      for(int j=0; j<numLayers[i]; j++) layerRotatable[i][j] = true;
560
      layerRotatable[i][numLayers[i]/2] = false;
561 29b82486 Leszek Koltunski
      }
562 59c20632 Leszek Koltunski
563
    return layerRotatable;
564 29b82486 Leszek Koltunski
    }
565
566
///////////////////////////////////////////////////////////////////////////////////////////////////
567
568 59c20632 Leszek Koltunski
  public int getMovementType()
569 29b82486 Leszek Koltunski
    {
570 59c20632 Leszek Koltunski
    return MOVEMENT_DODECAHEDRON;
571 29b82486 Leszek Koltunski
    }
572
573
///////////////////////////////////////////////////////////////////////////////////////////////////
574
575 59c20632 Leszek Koltunski
  public int getMovementSplit()
576 29b82486 Leszek Koltunski
    {
577 59c20632 Leszek Koltunski
    return TYPE_SPLIT_EDGE;
578 29b82486 Leszek Koltunski
    }
579
580
///////////////////////////////////////////////////////////////////////////////////////////////////
581
582 59c20632 Leszek Koltunski
  public int[][][] getEnabled()
583 29b82486 Leszek Koltunski
    {
584 59c20632 Leszek Koltunski
    return new int[][][]
585
      {
586
          {{2,3},{3,5},{1,5},{1,4},{2,4}},
587
          {{0,5},{2,5},{2,3},{3,4},{0,4}},
588
          {{2,3},{2,5},{0,5},{0,4},{3,4}},
589
          {{1,5},{3,5},{2,3},{2,4},{1,4}},
590
          {{0,3},{0,4},{4,5},{1,5},{1,3}},
591
          {{1,2},{1,4},{4,5},{0,5},{0,2}},
592
          {{4,5},{1,4},{1,2},{0,2},{0,5}},
593
          {{4,5},{0,4},{0,3},{1,3},{1,5}},
594
          {{0,2},{0,1},{1,3},{3,5},{2,5}},
595
          {{3,4},{2,4},{1,2},{0,1},{0,3}},
596
          {{2,4},{3,4},{0,3},{0,1},{1,2}},
597
          {{1,3},{0,1},{0,2},{2,5},{3,5}},
598
      };
599 29b82486 Leszek Koltunski
    }
600
601
///////////////////////////////////////////////////////////////////////////////////////////////////
602
603 59c20632 Leszek Koltunski
  public float[] getDist3D(int[] numLayers)
604 29b82486 Leszek Koltunski
    {
605 59c20632 Leszek Koltunski
    return null;
606
    }
607 e6b45809 Leszek Koltunski
608 59c20632 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
609
610
  public int getSolvedFunctionIndex()
611
    {
612
    return 0;
613
    }
614
615
///////////////////////////////////////////////////////////////////////////////////////////////////
616
617 a75ae1ee Leszek Koltunski
  public int getNumCubitFaces()
618 59c20632 Leszek Koltunski
    {
619
    return 6;
620
    }
621
622
///////////////////////////////////////////////////////////////////////////////////////////////////
623
// PUBLIC API
624
625
  public Static3D[] getRotationAxis()
626
    {
627
    return ROT_AXIS;
628 29b82486 Leszek Koltunski
    }
629
630
///////////////////////////////////////////////////////////////////////////////////////////////////
631
632
  public int[] getBasicAngle()
633
    {
634
    if( mBasicAngle ==null ) mBasicAngle = new int[] { 5,5,5,5,5,5 };
635
    return mBasicAngle;
636
    }
637
}