Revision 8e197e3e
Added by Leszek Koltunski 9 months ago
src/main/java/org/distorted/objectlib/algsolvers/implemented/SolverKilominx.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2024 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Magic Cube. // |
|
5 |
// // |
|
6 |
// Magic Cube is proprietary software licensed under an EULA which you should have received // |
|
7 |
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html // |
|
8 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
9 |
|
|
10 |
package org.distorted.objectlib.algsolvers.implemented; |
|
11 |
|
|
12 |
import org.distorted.library.type.Static3D; |
|
13 |
import org.distorted.objectlib.algsolvers.MoveProviderAlgs; |
|
14 |
import org.distorted.objectlib.algsolvers.MoveProviderAll; |
|
15 |
import org.distorted.objectlib.algsolvers.Phase; |
|
16 |
import org.distorted.objectlib.algsolvers.PhaseMitm; |
|
17 |
import org.distorted.objectlib.algsolvers.SolvedObject; |
|
18 |
import org.distorted.objectlib.algsolvers.TargetProvider; |
|
19 |
import org.distorted.objectlib.algsolvers.TargetProviderAll; |
|
20 |
import org.distorted.objectlib.algsolvers.TargetProviderOrie; |
|
21 |
import org.distorted.objectlib.algsolvers.TargetProviderPerm; |
|
22 |
import org.distorted.objectlib.objects.TwistyDodecahedron; |
|
23 |
|
|
24 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
25 |
|
|
26 |
public class SolverKilominx extends SolverAbstract |
|
27 |
{ |
|
28 |
@Override |
|
29 |
SolvedObject createObject() |
|
30 |
{ |
|
31 |
float[][] pos = TwistyDodecahedron.initializeCorners(); |
|
32 |
Static3D[] axis = TwistyDodecahedron.ROT_AXIS; |
|
33 |
int[] a = new int[] {5,5,5}; |
|
34 |
int[][] angles = new int[][] { a,a,a,a,a,a }; |
|
35 |
float[][] cuts = TwistyDodecahedron.genericGetCuts(3,0.5f); |
|
36 |
boolean[] r = {true,false,true}; |
|
37 |
boolean[][] rot = {r,r,r,r,r,r}; |
|
38 |
|
|
39 |
return new SolvedObject(pos,axis,angles,cuts,rot); |
|
40 |
} |
|
41 |
|
|
42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
43 |
|
|
44 |
@Override |
|
45 |
Phase[] createPhases(SolvedObject object) |
|
46 |
{ |
|
47 |
int[][] whiteFace = new int[][]{ {12,13,16,17} }; |
|
48 |
MoveProviderAll all = new MoveProviderAll(object); |
|
49 |
TargetProvider wcr = new TargetProviderAll(whiteFace); |
|
50 |
|
|
51 |
return new Phase[] |
|
52 |
{ |
|
53 |
new PhaseMitm( object, all, wcr, "White Face"), |
|
54 |
}; |
|
55 |
} |
|
56 |
} |
src/main/java/org/distorted/objectlib/objects/TwistyBandagedMegaminx.java | ||
---|---|---|
429 | 429 |
|
430 | 430 |
public float[][] getCuts(int[] numLayers) |
431 | 431 |
{ |
432 |
int param = getMetadata().getParam(); |
|
433 |
int size = numLayers[0]; |
|
434 |
float dist = (param==KILOMINX3 || param==KILOMINX5) ? 0.5f : 0.5f-MEGA_D; |
|
435 |
return genericGetCuts(size,dist); |
|
432 |
if( mCuts==null ) |
|
433 |
{ |
|
434 |
int param = getMetadata().getParam(); |
|
435 |
int size = numLayers[0]; |
|
436 |
float dist = (param==KILOMINX3 || param==KILOMINX5) ? 0.5f : 0.5f-MEGA_D; |
|
437 |
mCuts = genericGetCuts(size,dist); |
|
438 |
} |
|
439 |
|
|
440 |
return mCuts; |
|
436 | 441 |
} |
437 | 442 |
|
438 | 443 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyDodecahedron.java | ||
---|---|---|
32 | 32 |
static final int NUM_CORNERS = 20; |
33 | 33 |
static final int NUM_CENTERS = 12; |
34 | 34 |
static final int NUM_EDGES = 30; |
35 |
|
|
36 |
static final float SIN18 = (SQ5-1)/4; |
|
37 |
static final float COS18 = (float)(0.25f*Math.sqrt(10.0f+2.0f*SQ5)); |
|
35 |
static final float SIN18 = (SQ5-1)/4; |
|
36 |
static final float COS18 = (float)(0.25f*Math.sqrt(10.0f+2.0f*SQ5)); |
|
38 | 37 |
|
39 | 38 |
// the six rotation axis of a Minx. Must be normalized. |
40 |
static final Static3D[] ROT_AXIS = new Static3D[] |
|
39 |
public static final Static3D[] ROT_AXIS = new Static3D[]
|
|
41 | 40 |
{ |
42 | 41 |
new Static3D( C2/LEN, SIN54/LEN, 0 ), |
43 | 42 |
new Static3D( -C2/LEN, SIN54/LEN, 0 ), |
... | ... | |
48 | 47 |
}; |
49 | 48 |
|
50 | 49 |
private int[][] mBasicAngle; |
51 |
private float[][] mCuts;
|
|
50 |
protected float[][] mCuts;
|
|
52 | 51 |
float[][] mCenterCoords,mCorners; |
53 | 52 |
int[] mQuatEdgeIndices,mQuatCornerIndices; |
54 | 53 |
int[][] mEdgeMap,mCenterMap; |
... | ... | |
326 | 325 |
|
327 | 326 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
328 | 327 |
|
329 |
float[][] genericGetCuts(int numLayers, float dist) |
|
328 |
public static float[][] genericGetCuts(int numLayers, float dist)
|
|
330 | 329 |
{ |
331 |
if( mCuts==null ) |
|
330 |
float[][] cuts = new float[6][numLayers-1]; |
|
331 |
float D = numLayers* TouchControlDodecahedron.DIST3D; |
|
332 |
float X = 2*D/(2+SIN18); // height of the 'upper' part of a dodecahedron, i.e. put it on a table, |
|
333 |
// its height is then 2D, it has one 'lower' part of height X, one |
|
334 |
// 'middle' part of height Y and one upper part of height X again. |
|
335 |
int num = (numLayers-1)/2; |
|
336 |
float G = X*dist/num; // height of one Layer |
|
337 |
|
|
338 |
for(int i=0; i<num; i++) |
|
332 | 339 |
{ |
333 |
mCuts = new float[6][numLayers-1]; |
|
334 |
float D = numLayers* TouchControlDodecahedron.DIST3D; |
|
335 |
float X = 2*D/(2+SIN18); // height of the 'upper' part of a dodecahedron, i.e. put it on a table, |
|
336 |
// its height is then 2D, it has one 'lower' part of height X, one |
|
337 |
// 'middle' part of height Y and one upper part of height X again. |
|
338 |
int num = (numLayers-1)/2; |
|
339 |
float G = X*dist/num; // height of one Layer |
|
340 |
|
|
341 |
for(int i=0; i<num; i++) |
|
342 |
{ |
|
343 |
float cut = -D + (i+0.85f)*G; // 0.85? not fully correct; attempt to make it |
|
340 |
float cut = -D + (i+0.85f)*G; // 0.85? not fully correct; attempt to make it |
|
344 | 341 |
// easier to rotate the outer layers |
345 |
int j = 2*num-1-i; |
|
346 |
mCuts[0][i] = cut; |
|
347 |
mCuts[0][j] = -cut; |
|
348 |
mCuts[1][i] = cut; |
|
349 |
mCuts[1][j] = -cut; |
|
350 |
mCuts[2][i] = cut; |
|
351 |
mCuts[2][j] = -cut; |
|
352 |
mCuts[3][i] = cut; |
|
353 |
mCuts[3][j] = -cut; |
|
354 |
mCuts[4][i] = cut; |
|
355 |
mCuts[4][j] = -cut; |
|
356 |
mCuts[5][i] = cut; |
|
357 |
mCuts[5][j] = -cut; |
|
358 |
} |
|
342 |
int j = 2*num-1-i; |
|
343 |
cuts[0][i] = cut; |
|
344 |
cuts[0][j] = -cut; |
|
345 |
cuts[1][i] = cut; |
|
346 |
cuts[1][j] = -cut; |
|
347 |
cuts[2][i] = cut; |
|
348 |
cuts[2][j] = -cut; |
|
349 |
cuts[3][i] = cut; |
|
350 |
cuts[3][j] = -cut; |
|
351 |
cuts[4][i] = cut; |
|
352 |
cuts[4][j] = -cut; |
|
353 |
cuts[5][i] = cut; |
|
354 |
cuts[5][j] = -cut; |
|
359 | 355 |
} |
360 | 356 |
|
361 |
return mCuts;
|
|
362 |
}
|
|
357 |
return cuts;
|
|
358 |
} |
|
363 | 359 |
|
364 | 360 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
365 | 361 |
|
src/main/java/org/distorted/objectlib/objects/TwistyKilominx.java | ||
---|---|---|
66 | 66 |
|
67 | 67 |
public float[][] getCuts(int[] numLayers) |
68 | 68 |
{ |
69 |
return genericGetCuts(numLayers[0],0.5f); |
|
69 |
if( mCuts==null ) mCuts = genericGetCuts(numLayers[0],0.5f); |
|
70 |
return mCuts; |
|
70 | 71 |
} |
71 | 72 |
|
72 | 73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/objects/TwistyMegaminx.java | ||
---|---|---|
63 | 63 |
|
64 | 64 |
public float[][] getCuts(int[] numLayers) |
65 | 65 |
{ |
66 |
return genericGetCuts(numLayers[0],0.5f-MEGA_D); |
|
66 |
if( mCuts==null ) mCuts = genericGetCuts(numLayers[0],0.5f-MEGA_D); |
|
67 |
return mCuts; |
|
67 | 68 |
} |
68 | 69 |
|
69 | 70 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Beginnings of SolverKilominx