Revision 221a4090
Added by Leszek Koltunski about 3 years ago
src/main/java/org/distorted/objects/TwistyBandagedAbstract.java | ||
---|---|---|
30 | 30 |
import org.distorted.library.mesh.MeshSquare; |
31 | 31 |
import org.distorted.library.type.Static3D; |
32 | 32 |
import org.distorted.library.type.Static4D; |
33 |
import org.distorted.main.RubikSurfaceView; |
|
34 | 33 |
|
35 | 34 |
import java.util.Random; |
36 | 35 |
|
... | ... | |
389 | 388 |
} |
390 | 389 |
|
391 | 390 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
391 |
// TODO |
|
392 | 392 |
|
393 | 393 |
public boolean isSolved() |
394 | 394 |
{ |
... | ... | |
402 | 402 |
return true; |
403 | 403 |
} |
404 | 404 |
|
405 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
406 |
// return if the Cubit, when rotated with its own mQuatScramble, would have looked any different |
|
407 |
// then if it were rotated by quaternion 'quat'. |
|
408 |
// No it is not so simple as the quats need to be the same - imagine a 4x4x4 cube where the two |
|
409 |
// middle squares get interchanged. No visible difference! |
|
410 |
// |
|
411 |
// So: this is true iff the cubit |
|
412 |
// a) is a corner or edge and the quaternions are the same |
|
413 |
// b) is inside one of the faces and after rotations by both quats it ends up on the same face. |
|
414 |
|
|
415 |
private boolean thereIsNoVisibleDifference(Cubit cubit, int quatIndex) |
|
416 |
{ |
|
417 |
if ( cubit.mQuatIndex == quatIndex ) return true; |
|
418 |
|
|
419 |
int belongsToHowManyFaces = 0; |
|
420 |
int lastLayer = getNumLayers()-1; |
|
421 |
float row; |
|
422 |
final float MAX_ERROR = 0.01f; |
|
423 |
|
|
424 |
for(int i=0; i<NUM_AXIS; i++) |
|
425 |
{ |
|
426 |
row = cubit.mRotationRow[i]; |
|
427 |
if( (row <MAX_ERROR && row >-MAX_ERROR) || |
|
428 |
(row-lastLayer<MAX_ERROR && row-lastLayer>-MAX_ERROR) ) belongsToHowManyFaces++; |
|
429 |
} |
|
430 |
|
|
431 |
switch(belongsToHowManyFaces) |
|
432 |
{ |
|
433 |
case 0 : return true ; // 'inside' cubit that does not lie on any face |
|
434 |
case 1 : // cubit that lies inside one of the faces |
|
435 |
Static3D orig = cubit.getOrigPosition(); |
|
436 |
Static4D quat1 = QUATS[quatIndex]; |
|
437 |
Static4D quat2 = QUATS[cubit.mQuatIndex]; |
|
438 |
|
|
439 |
Static4D cubitCenter = new Static4D( orig.get0(), orig.get1(), orig.get2(), 0); |
|
440 |
Static4D rotated1 = RubikSurfaceView.rotateVectorByQuat( cubitCenter, quat1 ); |
|
441 |
Static4D rotated2 = RubikSurfaceView.rotateVectorByQuat( cubitCenter, quat2 ); |
|
442 |
|
|
443 |
float row1, row2; |
|
444 |
float x1 = rotated1.get0(); |
|
445 |
float y1 = rotated1.get1(); |
|
446 |
float z1 = rotated1.get2(); |
|
447 |
float x2 = rotated2.get0(); |
|
448 |
float y2 = rotated2.get1(); |
|
449 |
float z2 = rotated2.get2(); |
|
450 |
|
|
451 |
for(int i=0; i<NUM_AXIS; i++) |
|
452 |
{ |
|
453 |
row1 = computeRow(x1,y1,z1,i); |
|
454 |
row2 = computeRow(x2,y2,z2,i); |
|
455 |
|
|
456 |
if( (row1==0 && row2==0) || (row1==lastLayer && row2==lastLayer) ) return true; |
|
457 |
} |
|
458 |
return false; |
|
459 |
|
|
460 |
default: return false; // edge or corner |
|
461 |
} |
|
462 |
} |
|
463 |
|
|
464 | 405 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
465 | 406 |
// only needed for solvers - there are no Bandaged solvers ATM) |
466 | 407 |
|
Also available in: Unified diff
Simplification with objects.