Revision e42a9e87
Added by Leszek Koltunski over 2 years ago
src/main/java/org/distorted/objects/TwistyObject.java | ||
---|---|---|
454 | 454 |
if( mSolvedFunctionIndex==0 ) return isSolved0(); |
455 | 455 |
if( mSolvedFunctionIndex==1 ) return isSolved1(); |
456 | 456 |
if( mSolvedFunctionIndex==2 ) return isSolved2(); |
457 |
if( mSolvedFunctionIndex==3 ) return isSolved3(); |
|
457 | 458 |
|
458 | 459 |
return false; |
459 | 460 |
} |
... | ... | |
588 | 589 |
} |
589 | 590 |
|
590 | 591 |
return ( qX==qY && qX==qZ ) || ( qY==mulQuat(qX,2) && qZ==mulQuat(qX,8) ); |
592 |
} |
|
593 |
|
|
594 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
595 |
// Square-2 is solved iff |
|
596 |
// a) all of its cubits are rotated with the same quat |
|
597 |
// b) its two 'middle' cubits are rotated with the same quat, the 6 'front' and 6 'back' |
|
598 |
// edges and corners with this quat multiplied by QUATS[18] (i.e. those are upside down) |
|
599 |
// and all the 12 left and right edges and corners also with the same quat multiplied by |
|
600 |
// QUATS[12] - i.e. also upside down. |
|
601 |
|
|
602 |
public boolean isSolved3() |
|
603 |
{ |
|
604 |
int index = CUBITS[0].mQuatIndex; |
|
605 |
|
|
606 |
if( CUBITS[1].mQuatIndex!=index ) return false; |
|
607 |
|
|
608 |
boolean solved = true; |
|
609 |
|
|
610 |
for(int i=2; i<NUM_CUBITS; i++) |
|
611 |
{ |
|
612 |
if( CUBITS[i].mQuatIndex!=index ) |
|
613 |
{ |
|
614 |
solved = false; |
|
615 |
break; |
|
616 |
} |
|
617 |
} |
|
591 | 618 |
|
619 |
if( solved ) return true; |
|
620 |
|
|
621 |
int indexX = mulQuat(index,12); // QUATS[12] = 180deg (1,0,0) |
|
622 |
int indexZ = mulQuat(index,18); // QUATS[18] = 180deg (0,0,1) |
|
623 |
|
|
624 |
for(int i= 2; i< 18; i+=2) if( CUBITS[i].mQuatIndex != indexZ ) return false; |
|
625 |
for(int i= 3; i< 18; i+=2) if( CUBITS[i].mQuatIndex != indexX ) return false; |
|
626 |
for(int i=18; i<NUM_CUBITS; i+=2) if( CUBITS[i].mQuatIndex != indexX ) return false; |
|
627 |
for(int i=19; i<NUM_CUBITS; i+=2) if( CUBITS[i].mQuatIndex != indexZ ) return false; |
|
628 |
|
|
629 |
return true; |
|
592 | 630 |
} |
593 | 631 |
|
594 | 632 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Fix the Square-2 isSolved() (it was wrong even before!)