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