Revision 57e86ed0
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/objects/TwistySquare.java | ||
---|---|---|
289 | 289 |
return BASIC_ANGLE; |
290 | 290 |
} |
291 | 291 |
|
292 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
293 |
|
|
294 |
public boolean isSolved() |
|
295 |
{ |
|
296 |
int index = CUBITS[0].mQuatIndex; |
|
297 |
|
|
298 |
for(int i=1; i<NUM_CUBITS; i++) |
|
299 |
{ |
|
300 |
if( CUBITS[i].mQuatIndex != index ) return false; |
|
301 |
} |
|
302 |
|
|
303 |
return true; |
|
304 |
} |
|
305 |
|
|
306 | 292 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
307 | 293 |
// only needed for solvers - there are no Square solvers ATM) |
308 | 294 |
|
src/main/java/org/distorted/objects/TwistySquare1.java | ||
---|---|---|
515 | 515 |
} |
516 | 516 |
} |
517 | 517 |
|
518 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
519 |
|
|
520 |
public boolean isSolved() |
|
521 |
{ |
|
522 |
int index = CUBITS[0].mQuatIndex; |
|
523 |
|
|
524 |
for(int i=1; i<NUM_CUBITS; i++) |
|
525 |
{ |
|
526 |
if( CUBITS[i].mQuatIndex != index ) return false; |
|
527 |
} |
|
528 |
|
|
529 |
return true; |
|
530 |
} |
|
531 |
|
|
518 | 532 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
519 | 533 |
|
520 | 534 |
public int getObjectName(int numLayers) |
src/main/java/org/distorted/objects/TwistySquare2.java | ||
---|---|---|
327 | 327 |
} |
328 | 328 |
} |
329 | 329 |
|
330 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
331 |
// Square-2 is solved iff |
|
332 |
// a) all of its cubits are rotated with the same quat |
|
333 |
// b) its two 'middle' cubits are rotated with the same quat, the 6 'front' and 6 'back' |
|
334 |
// edges and corners with this quat multiplied by QUATS[18] (i.e. those are upside down) |
|
335 |
// and all the 12 left and right edges and corners also with the same quat multiplied by |
|
336 |
// QUATS[12] - i.e. also upside down. |
|
337 |
|
|
338 |
public boolean isSolved() |
|
339 |
{ |
|
340 |
int index = CUBITS[0].mQuatIndex; |
|
341 |
|
|
342 |
if( CUBITS[1].mQuatIndex!=index ) return false; |
|
343 |
|
|
344 |
int indexX = mulQuat(index,12); // QUATS[12] = 180deg (1,0,0) |
|
345 |
int indexZ = mulQuat(index,18); // QUATS[18] = 180deg (0,0,1) |
|
346 |
|
|
347 |
for(int i=2; i<18; i+=2) |
|
348 |
{ |
|
349 |
if( CUBITS[i].mQuatIndex != index && CUBITS[i].mQuatIndex != indexZ ) return false; |
|
350 |
} |
|
351 |
for(int i=3; i<18; i+=2) |
|
352 |
{ |
|
353 |
if( CUBITS[i].mQuatIndex != index && CUBITS[i].mQuatIndex != indexX ) return false; |
|
354 |
} |
|
355 |
for(int i=18; i<NUM_CUBITS; i+=2) |
|
356 |
{ |
|
357 |
if( CUBITS[i].mQuatIndex != index && CUBITS[i].mQuatIndex != indexX ) return false; |
|
358 |
} |
|
359 |
for(int i=19; i<NUM_CUBITS; i+=2) |
|
360 |
{ |
|
361 |
if( CUBITS[i].mQuatIndex != index && CUBITS[i].mQuatIndex != indexZ ) return false; |
|
362 |
} |
|
363 |
|
|
364 |
return true; |
|
365 |
} |
|
366 |
|
|
330 | 367 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
331 | 368 |
|
332 | 369 |
public int getObjectName(int numLayers) |
Also available in: Unified diff
Square-2: correct detecting the solved state.