Revision 7437ebb3
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/object/Cubit.java | ||
|---|---|---|
| 253 | 253 |
|
| 254 | 254 |
int belongsToHowManyFaces = 0; |
| 255 | 255 |
int size = mParent.getSize()-1; |
| 256 |
int row; |
|
| 256 |
float row; |
|
| 257 |
final float MAX_ERROR = 0.01f; |
|
| 257 | 258 |
|
| 258 | 259 |
for(int i=0; i<mNumAxis; i++) |
| 259 | 260 |
{
|
| 260 |
row = (int)(mRotationRow[i]+0.5f); |
|
| 261 |
if( row==0 || row==size ) belongsToHowManyFaces++; |
|
| 261 |
row = mRotationRow[i]; |
|
| 262 |
if( (row <MAX_ERROR && row >-MAX_ERROR) || |
|
| 263 |
(row-size<MAX_ERROR && row-size>-MAX_ERROR) ) belongsToHowManyFaces++; |
|
| 262 | 264 |
} |
| 263 | 265 |
|
| 264 | 266 |
switch(belongsToHowManyFaces) |
| ... | ... | |
| 273 | 275 |
Static4D rotated1 = RubikSurfaceView.rotateVectorByQuat( cubitCenter, quat); |
| 274 | 276 |
Static4D rotated2 = RubikSurfaceView.rotateVectorByQuat( cubitCenter, mQuatScramble ); |
| 275 | 277 |
|
| 276 |
int row1, row2;
|
|
| 278 |
float row1, row2, row3, row4;
|
|
| 277 | 279 |
float ax,ay,az; |
| 278 | 280 |
Static3D axis; |
| 279 | 281 |
float x1 = rotated1.get0(); |
| ... | ... | |
| 290 | 292 |
ay = axis.get1(); |
| 291 | 293 |
az = axis.get2(); |
| 292 | 294 |
|
| 293 |
row1 = (int)(( (x1*ax + y1*ay + z1*az) - mParent.mStart)/mParent.mStep + 0.5f); |
|
| 294 |
row2 = (int)(( (x2*ax + y2*ay + z2*az) - mParent.mStart)/mParent.mStep + 0.5f); |
|
| 295 |
row1 = ((x1*ax + y1*ay + z1*az) - mParent.mStart) / mParent.mStep; |
|
| 296 |
row2 = ((x2*ax + y2*ay + z2*az) - mParent.mStart) / mParent.mStep; |
|
| 297 |
row3 = row1 - size; |
|
| 298 |
row4 = row2 - size; |
|
| 295 | 299 |
|
| 296 |
if( (row1==0 && row2==0) || (row1==size && row2==size) ) |
|
| 300 |
if( (row1<MAX_ERROR && row1>-MAX_ERROR && row2<MAX_ERROR && row2>-MAX_ERROR) || |
|
| 301 |
(row3<MAX_ERROR && row3>-MAX_ERROR && row4<MAX_ERROR && row4>-MAX_ERROR) ) |
|
| 297 | 302 |
{
|
| 298 | 303 |
return true; |
| 299 | 304 |
} |
Also available in: Unified diff
Still a fix for the previous fix - cubits lie on faces only if their RotationRow is very close to 0 or mSize-1, and not when their RotationRow rounded to the nearest integer is 0 or mSize-1 ! ( counterexample: the rotated tetrahedrons of Pyraminx )