1 |
a64e07d0
|
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.objects;
|
21 |
|
|
|
22 |
|
|
import android.content.res.Resources;
|
23 |
|
|
|
24 |
af0de0af
|
Leszek Koltunski
|
import org.distorted.helpers.ObjectSticker;
|
25 |
aa26ba7f
|
Leszek Koltunski
|
import org.distorted.helpers.ScrambleState;
|
26 |
a64e07d0
|
Leszek Koltunski
|
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 |
efa81f0c
|
Leszek Koltunski
|
abstract class TwistyMinx extends Twisty12
|
35 |
a64e07d0
|
Leszek Koltunski
|
{
|
36 |
ead91342
|
Leszek Koltunski
|
static final int NUM_CORNERS = 20;
|
37 |
|
|
static final int NUM_CENTERS = 12;
|
38 |
|
|
static final int NUM_EDGES = 30;
|
39 |
|
|
|
40 |
bb11be2a
|
Leszek Koltunski
|
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 |
a64e07d0
|
Leszek Koltunski
|
|
49 |
|
|
// the six rotation axis of a Minx. Must be normalized.
|
50 |
|
|
static final Static3D[] ROT_AXIS = new Static3D[]
|
51 |
|
|
{
|
52 |
bb11be2a
|
Leszek Koltunski
|
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 |
a64e07d0
|
Leszek Koltunski
|
};
|
59 |
|
|
|
60 |
af0de0af
|
Leszek Koltunski
|
private ScrambleState[] mStates;
|
61 |
|
|
private int[] mBasicAngle;
|
62 |
|
|
private int[] mFaceMap;
|
63 |
e9a87113
|
Leszek Koltunski
|
private Movement mMovement;
|
64 |
af0de0af
|
Leszek Koltunski
|
Static4D[] mQuats;
|
65 |
|
|
float[][] mCenterCoords;
|
66 |
|
|
float[][] mCorners;
|
67 |
|
|
int[][] mCornerFaceMap;
|
68 |
|
|
int[] mQuatEdgeIndices;
|
69 |
|
|
int[] mQuatCornerIndices;
|
70 |
|
|
int[][] mEdgeMap;
|
71 |
|
|
int[][] mCenterMap;
|
72 |
|
|
Static4D[] mBasicCornerV, mCurrCornerV;
|
73 |
|
|
ObjectSticker[] mStickers;
|
74 |
a480ee80
|
Leszek Koltunski
|
|
75 |
af0de0af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
76 |
a64e07d0
|
Leszek Koltunski
|
|
77 |
af0de0af
|
Leszek Koltunski
|
TwistyMinx(int numLayers, int realSize, Static4D quat, DistortedTexture texture, MeshSquare mesh,
|
78 |
|
|
DistortedEffects effects, int[][] moves, ObjectList obj, Resources res, int scrWidth)
|
79 |
|
|
{
|
80 |
|
|
super(numLayers, realSize, quat, texture, mesh, effects, moves, obj, res, scrWidth);
|
81 |
|
|
}
|
82 |
a64e07d0
|
Leszek Koltunski
|
|
83 |
91792184
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
84 |
|
|
|
85 |
|
|
ScrambleState[] getScrambleStates()
|
86 |
|
|
{
|
87 |
|
|
if( mStates==null )
|
88 |
|
|
{
|
89 |
|
|
int numLayers = getNumLayers();
|
90 |
|
|
initializeScrambleStates(numLayers);
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
return mStates;
|
94 |
|
|
}
|
95 |
7764a67a
|
Leszek Koltunski
|
|
96 |
af0de0af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
97 |
7764a67a
|
Leszek Koltunski
|
|
98 |
af0de0af
|
Leszek Koltunski
|
void initializeCornerV()
|
99 |
|
|
{
|
100 |
|
|
mBasicCornerV = new Static4D[3];
|
101 |
|
|
mCurrCornerV = new Static4D[3];
|
102 |
|
|
|
103 |
387b6326
|
Leszek Koltunski
|
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 |
af0de0af
|
Leszek Koltunski
|
}
|
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 |
d38f1397
|
Leszek Koltunski
|
|
130 |
af0de0af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
ead91342
|
Leszek Koltunski
|
{
|
140 |
7a606778
|
Leszek Koltunski
|
{ 0, 12, 0, 8}, //0
|
141 |
ead91342
|
Leszek Koltunski
|
{ 12, 4, 0, 9},
|
142 |
|
|
{ 4, 14, 0, 4},
|
143 |
|
|
{ 14, 2, 0, 11},
|
144 |
|
|
{ 2, 0, 0, 1},
|
145 |
7a606778
|
Leszek Koltunski
|
{ 14, 9, 11, 4}, //5
|
146 |
|
|
{ 9, 11, 11, 3},
|
147 |
|
|
{ 11, 18, 11, 2},
|
148 |
|
|
{ 18, 2, 11, 1},
|
149 |
ead91342
|
Leszek Koltunski
|
{ 18, 6, 1, 2},
|
150 |
7a606778
|
Leszek Koltunski
|
{ 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 |
ead91342
|
Leszek Koltunski
|
{ 13, 5, 9, 5},
|
157 |
|
|
{ 5, 4, 9, 4},
|
158 |
7a606778
|
Leszek Koltunski
|
{ 5, 15, 4, 5},
|
159 |
|
|
{ 15, 9, 4, 3},
|
160 |
|
|
{ 11, 19, 2, 3}, //20
|
161 |
ead91342
|
Leszek Koltunski
|
{ 19, 7, 2, 6},
|
162 |
|
|
{ 7, 6, 2, 7},
|
163 |
|
|
{ 7, 17, 7, 6},
|
164 |
|
|
{ 17, 10, 7, 10},
|
165 |
7a606778
|
Leszek Koltunski
|
{ 17, 1, 10, 6}, //25
|
166 |
ead91342
|
Leszek Koltunski
|
{ 1, 3, 5, 6},
|
167 |
|
|
{ 3, 19, 3, 6},
|
168 |
|
|
{ 1, 13, 10, 5},
|
169 |
7a606778
|
Leszek Koltunski
|
{ 3, 15, 5, 3},
|
170 |
ead91342
|
Leszek Koltunski
|
};
|
171 |
af0de0af
|
Leszek Koltunski
|
}
|
172 |
ead91342
|
Leszek Koltunski
|
|
173 |
af0de0af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
174 |
ead91342
|
Leszek Koltunski
|
|
175 |
af0de0af
|
Leszek Koltunski
|
void initializeQuatIndices()
|
176 |
ead91342
|
Leszek Koltunski
|
{
|
177 |
af0de0af
|
Leszek Koltunski
|
mQuatEdgeIndices = new int[]
|
178 |
ead91342
|
Leszek Koltunski
|
{
|
179 |
af0de0af
|
Leszek Koltunski
|
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 |
ead91342
|
Leszek Koltunski
|
|
190 |
af0de0af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
191 |
ead91342
|
Leszek Koltunski
|
|
192 |
af0de0af
|
Leszek Koltunski
|
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 |
ead91342
|
Leszek Koltunski
|
|
219 |
af0de0af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
220 |
ead91342
|
Leszek Koltunski
|
|
221 |
af0de0af
|
Leszek Koltunski
|
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 |
ead91342
|
Leszek Koltunski
|
}
|
292 |
|
|
|
293 |
af0de0af
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
294 |
|
|
// Coordinates of all 20 corners of a Minx
|
295 |
ead91342
|
Leszek Koltunski
|
|
296 |
af0de0af
|
Leszek Koltunski
|
void initializeCorners()
|
297 |
ead91342
|
Leszek Koltunski
|
{
|
298 |
387b6326
|
Leszek Koltunski
|
float cA = 1.5f;
|
299 |
|
|
float cB = 3*C2;
|
300 |
|
|
float cC = 3*SIN54;
|
301 |
|
|
|
302 |
af0de0af
|
Leszek Koltunski
|
mCorners = new float[][]
|
303 |
|
|
{
|
304 |
387b6326
|
Leszek Koltunski
|
{ 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 |
af0de0af
|
Leszek Koltunski
|
};
|
325 |
ead91342
|
Leszek Koltunski
|
}
|
326 |
|
|
|
327 |
a64e07d0
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
328 |
|
|
|
329 |
af0de0af
|
Leszek Koltunski
|
void initializeCenterCoords()
|
330 |
a64e07d0
|
Leszek Koltunski
|
{
|
331 |
af0de0af
|
Leszek Koltunski
|
if( mCorners==null ) initializeCorners();
|
332 |
|
|
if( mCenterMap==null ) initializeCenterMap();
|
333 |
aa26ba7f
|
Leszek Koltunski
|
|
334 |
af0de0af
|
Leszek Koltunski
|
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 |
a64e07d0
|
Leszek Koltunski
|
}
|
363 |
|
|
|
364 |
a480ee80
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
365 |
|
|
|
366 |
aa26ba7f
|
Leszek Koltunski
|
private int[] generateL(int numLayers, int index)
|
367 |
a480ee80
|
Leszek Koltunski
|
{
|
368 |
aa26ba7f
|
Leszek Koltunski
|
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 |
a480ee80
|
Leszek Koltunski
|
}
|
389 |
|
|
|
390 |
a64e07d0
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
391 |
|
|
|
392 |
aa26ba7f
|
Leszek Koltunski
|
private int[] generateR(int numLayers, int index)
|
393 |
a64e07d0
|
Leszek Koltunski
|
{
|
394 |
aa26ba7f
|
Leszek Koltunski
|
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 |
a64e07d0
|
Leszek Koltunski
|
}
|
417 |
|
|
|
418 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
419 |
|
|
|
420 |
aa26ba7f
|
Leszek Koltunski
|
private int[] generateB(int numLayers, int index)
|
421 |
a64e07d0
|
Leszek Koltunski
|
{
|
422 |
aa26ba7f
|
Leszek Koltunski
|
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 |
a64e07d0
|
Leszek Koltunski
|
}
|
447 |
|
|
|
448 |
169219a7
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
449 |
|
|
|
450 |
aa26ba7f
|
Leszek Koltunski
|
private void initializeScrambleStates(int numLayers)
|
451 |
169219a7
|
Leszek Koltunski
|
{
|
452 |
aa26ba7f
|
Leszek Koltunski
|
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 |
169219a7
|
Leszek Koltunski
|
}
|
489 |
|
|
|
490 |
a64e07d0
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
491 |
|
|
|
492 |
aa26ba7f
|
Leszek Koltunski
|
int[] getSolvedQuats(int cubit, int numLayers)
|
493 |
a64e07d0
|
Leszek Koltunski
|
{
|
494 |
af0de0af
|
Leszek Koltunski
|
if( mQuats==null ) initializeQuats();
|
495 |
|
|
if( mFaceMap==null ) mFaceMap = new int[] {8,10,3,7,1,11,9,2,4,0,5,6};
|
496 |
aa26ba7f
|
Leszek Koltunski
|
int status = retCubitSolvedStatus(cubit,numLayers);
|
497 |
af0de0af
|
Leszek Koltunski
|
return status<0 ? null : buildSolvedQuats(MovementMinx.FACE_AXIS[mFaceMap[status]],mQuats);
|
498 |
a64e07d0
|
Leszek Koltunski
|
}
|
499 |
|
|
|
500 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
501 |
|
|
|
502 |
aa26ba7f
|
Leszek Koltunski
|
Static4D[] getQuats()
|
503 |
a64e07d0
|
Leszek Koltunski
|
{
|
504 |
af0de0af
|
Leszek Koltunski
|
if( mQuats==null ) initializeQuats();
|
505 |
|
|
return mQuats;
|
506 |
a64e07d0
|
Leszek Koltunski
|
}
|
507 |
|
|
|
508 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
509 |
|
|
|
510 |
aa26ba7f
|
Leszek Koltunski
|
int getSolvedFunctionIndex()
|
511 |
a64e07d0
|
Leszek Koltunski
|
{
|
512 |
aa26ba7f
|
Leszek Koltunski
|
return 0;
|
513 |
a64e07d0
|
Leszek Koltunski
|
}
|
514 |
|
|
|
515 |
0812242b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
516 |
|
|
|
517 |
aa26ba7f
|
Leszek Koltunski
|
int getNumCubitFaces()
|
518 |
0812242b
|
Leszek Koltunski
|
{
|
519 |
efa81f0c
|
Leszek Koltunski
|
return 6;
|
520 |
4c737817
|
Leszek Koltunski
|
}
|
521 |
|
|
|
522 |
0812242b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
523 |
|
|
// PUBLIC API
|
524 |
|
|
|
525 |
|
|
public Static3D[] getRotationAxis()
|
526 |
|
|
{
|
527 |
|
|
return ROT_AXIS;
|
528 |
|
|
}
|
529 |
|
|
|
530 |
e9a87113
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
531 |
|
|
|
532 |
|
|
public Movement getMovement()
|
533 |
|
|
{
|
534 |
|
|
if( mMovement==null ) mMovement = new MovementMinx();
|
535 |
|
|
return mMovement;
|
536 |
|
|
}
|
537 |
|
|
|
538 |
0812242b
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
539 |
|
|
|
540 |
|
|
public int[] getBasicAngle()
|
541 |
|
|
{
|
542 |
af0de0af
|
Leszek Koltunski
|
if( mBasicAngle ==null ) mBasicAngle = new int[] { 5,5,5,5,5,5 };
|
543 |
|
|
return mBasicAngle;
|
544 |
0812242b
|
Leszek Koltunski
|
}
|
545 |
a64e07d0
|
Leszek Koltunski
|
}
|