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