Revision d2e06841
Added by Leszek Koltunski 10 months ago
src/main/java/org/distorted/objectlib/bandaged/BandagedObjectMegaminx.java | ||
---|---|---|
10 | 10 |
package org.distorted.objectlib.bandaged; |
11 | 11 |
|
12 | 12 |
import static org.distorted.objectlib.main.TwistyObject.SQ5; |
13 |
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.C2; |
|
13 | 14 |
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.COS54; |
15 |
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.LEN; |
|
14 | 16 |
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.SIN54; |
15 | 17 |
|
16 | 18 |
import org.distorted.library.main.DistortedScreen; |
... | ... | |
35 | 37 |
private static final int NUM_CENTERS = 12; |
36 | 38 |
private static final int NUM_EDGES = 30; |
37 | 39 |
|
40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
41 |
|
|
42 |
private float[][] getCuts(int[] numLayers) |
|
43 |
{ |
|
44 |
int numL = numLayers[0]; |
|
45 |
int distL = numL; |
|
46 |
boolean megaminx = isMegaminx(numL); |
|
47 |
float dist = megaminx ? 0.5f-MEGA_D : 0.5f; |
|
48 |
if( (numL%2)==0 ) numL++; |
|
49 |
|
|
50 |
float[][] ret = new float[6][numL-1]; |
|
51 |
float D = distL*TouchControlDodecahedron.DIST3D; |
|
52 |
float X = 2*D/(2+SIN18); // height of the 'upper' part of a dodecahedron, i.e. put it on a table, |
|
53 |
// its height is then 2D, it has one 'lower' part of height X, one |
|
54 |
// 'middle' part of height Y and one upper part of height X again. |
|
55 |
int num = (numL-1)/2; |
|
56 |
float G = X*dist/num; // height of one Layer |
|
57 |
|
|
58 |
for(int i=0; i<num; i++) |
|
59 |
{ |
|
60 |
float cut = -D + (i+0.85f)*G; // 0.85? not fully correct; attempt to make it |
|
61 |
// easier to rotate the outer layers |
|
62 |
int j = 2*num-1-i; |
|
63 |
ret[0][i] = cut; |
|
64 |
ret[0][j] = -cut; |
|
65 |
ret[1][i] = cut; |
|
66 |
ret[1][j] = -cut; |
|
67 |
ret[2][i] = cut; |
|
68 |
ret[2][j] = -cut; |
|
69 |
ret[3][i] = cut; |
|
70 |
ret[3][j] = -cut; |
|
71 |
ret[4][i] = cut; |
|
72 |
ret[4][j] = -cut; |
|
73 |
ret[5][i] = cut; |
|
74 |
ret[5][j] = -cut; |
|
75 |
} |
|
76 |
|
|
77 |
return ret; |
|
78 |
} |
|
79 |
|
|
38 | 80 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
39 | 81 |
// The pair (distance,angle) defines a point P in R^2 in polar coordinate system. Let V be the vector |
40 | 82 |
// from the center of the coordinate system to P. |
... | ... | |
167 | 209 |
|
168 | 210 |
case 5: float x5_0 = 2.5f*(0.5f-MEGA_D); |
169 | 211 |
float x5_1 = 2.5f*(0.5f+MEGA_D); |
170 |
float x5_2 = 2.5f*(0.5f-MEGA_D)*COS18;
|
|
171 |
float x5_3 = x5_1 + 2.5f*(0.5f-MEGA_D)*SIN18;
|
|
172 |
float x5_4 = 2.5f*SIN54 - x5_2; |
|
212 |
float x5_2 = x5_0*COS18;
|
|
213 |
float x5_3 = x5_1 + x5_0*SIN18;
|
|
214 |
float x5_4 = 2.5f*SIN54/COS54 - x5_2;
|
|
173 | 215 |
float d5_0 = len-x5_0*x5_0; |
174 | 216 |
float d5_1 = len-x5_1*x5_1; |
175 | 217 |
float d5_2 = len-x5_2*x5_2; |
... | ... | |
186 | 228 |
return false; |
187 | 229 |
} |
188 | 230 |
|
231 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
232 |
|
|
233 |
float[][] getRotAxis() |
|
234 |
{ |
|
235 |
return new float[][] |
|
236 |
{ |
|
237 |
{ C2/LEN, SIN54/LEN, 0 }, |
|
238 |
{ -C2/LEN, SIN54/LEN, 0 }, |
|
239 |
{ 0 , C2/LEN, SIN54/LEN }, |
|
240 |
{ 0 , -C2/LEN, SIN54/LEN }, |
|
241 |
{ SIN54/LEN, 0 , C2/LEN }, |
|
242 |
{ SIN54/LEN, 0 , -C2/LEN } |
|
243 |
}; |
|
244 |
} |
|
245 |
|
|
189 | 246 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
190 | 247 |
|
191 | 248 |
float[][][] getPositions() |
... | ... | |
229 | 286 |
|
230 | 287 |
public BandagedObjectMegaminx(DistortedScreen screen) |
231 | 288 |
{ |
232 |
super(screen,6);
|
|
289 |
super(screen); |
|
233 | 290 |
} |
234 | 291 |
|
235 | 292 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
269 | 326 |
|
270 | 327 |
mMax = x; |
271 | 328 |
mNumCubits = numCubits(x); |
329 |
mCuts = getCuts(mSize); |
|
272 | 330 |
return true; |
273 | 331 |
} |
274 | 332 |
|
Also available in: Unified diff
progress with TwistyBandagedMegaminx.