Project

General

Profile

« Previous | Next » 

Revision 348dfe69

Added by Leszek Koltunski over 4 years ago

Adjustment to Static's API.

View differences:

src/main/java/org/distorted/object/RubikCube.java
104 104
      {
105 105
      Static4D quat = mQuatScramble[i][j][k];
106 106

  
107
      float x = quat.get1();
108
      float y = quat.get2();
109
      float z = quat.get3();
110
      float w = quat.get4();
107
      float x = quat.get0();
108
      float y = quat.get1();
109
      float z = quat.get2();
110
      float w = quat.get3();
111 111
      float diff;
112 112

  
113 113
      for(float legal: LEGAL)
......
177 177
      {
178 178
      switch(vector)
179 179
        {
180
        case VECTX: return mCurrentPosition[x][y][z].get1()==row;
181
        case VECTY: return mCurrentPosition[x][y][z].get2()==row;
182
        case VECTZ: return mCurrentPosition[x][y][z].get3()==row;
180
        case VECTX: return mCurrentPosition[x][y][z].get0()==row;
181
        case VECTY: return mCurrentPosition[x][y][z].get1()==row;
182
        case VECTZ: return mCurrentPosition[x][y][z].get2()==row;
183 183
        }
184 184

  
185 185
      return false;
......
191 191
      {
192 192
      Static3D current = mCurrentPosition[x][y][z];
193 193
      float diff = 0.5f*(mSize-1);
194
      float cubitCenterX = current.get1() - diff;
195
      float cubitCenterY = current.get2() - diff;
196
      float cubitCenterZ = current.get3() - diff;
194
      float cubitCenterX = current.get0() - diff;
195
      float cubitCenterY = current.get1() - diff;
196
      float cubitCenterZ = current.get2() - diff;
197 197

  
198 198
      Static4D cubitCenter =  new Static4D(cubitCenterX, cubitCenterY, cubitCenterZ, 0);
199 199
      Static4D rotatedCenter = RubikSurfaceView.rotateVectorByQuat( cubitCenter, quat);
200 200

  
201
      float rotatedX = rotatedCenter.get1() + diff;
202
      float rotatedY = rotatedCenter.get2() + diff;
203
      float rotatedZ = rotatedCenter.get3() + diff;
201
      float rotatedX = rotatedCenter.get0() + diff;
202
      float rotatedY = rotatedCenter.get1() + diff;
203
      float rotatedZ = rotatedCenter.get2() + diff;
204 204

  
205 205
      int roundedX = (int)(rotatedX+0.1f);
206 206
      int roundedY = (int)(rotatedY+0.1f);
207 207
      int roundedZ = (int)(rotatedZ+0.1f);
208 208

  
209
      mCurrentPosition[x][y][z].set1(roundedX);
210
      mCurrentPosition[x][y][z].set2(roundedY);
211
      mCurrentPosition[x][y][z].set3(roundedZ);
209
      mCurrentPosition[x][y][z].set0(roundedX);
210
      mCurrentPosition[x][y][z].set1(roundedY);
211
      mCurrentPosition[x][y][z].set2(roundedZ);
212 212
      }
213 213

  
214 214
///////////////////////////////////////////////////////////////////////////////////////////////////
......
342 342
      mRotAxis = vector;
343 343
      mRotRow  = row;
344 344

  
345
      mRotationAngleStatic.set1(0.0f);
345
      mRotationAngleStatic.set0(0.0f);
346 346

  
347 347
      for(int x=0; x<mSize; x++)
348 348
        for(int y=0; y<mSize; y++)
......
361 361

  
362 362
    public void continueRotation(float angleInDegrees)
363 363
      {
364
      mRotationAngleStatic.set1(angleInDegrees);
364
      mRotationAngleStatic.set0(angleInDegrees);
365 365
      }
366 366

  
367 367
///////////////////////////////////////////////////////////////////////////////////////////////////
......
394 394

  
395 395
                  if( pointNum>=1 )
396 396
                    {
397
                    float startingAngle = mRotationAngle[x][y][z].getPoint(pointNum-1).get1();
397
                    float startingAngle = mRotationAngle[x][y][z].getPoint(pointNum-1).get0();
398 398
                    int nearestAngleInDegrees = computeNearestAngle(startingAngle);
399
                    mRotationAngleStatic.set1(startingAngle);
400
                    mRotationAngleFinal.set1(nearestAngleInDegrees);
401
                    mRotationAngleMiddle.set1( nearestAngleInDegrees + (nearestAngleInDegrees-startingAngle)*0.2f );
399
                    mRotationAngleStatic.set0(startingAngle);
400
                    mRotationAngleFinal.set0(nearestAngleInDegrees);
401
                    mRotationAngleMiddle.set0( nearestAngleInDegrees + (nearestAngleInDegrees-startingAngle)*0.2f );
402 402
                    }
403 403
                  else
404 404
                    {
......
562 562
      {
563 563
      Static4D q = mQuatScramble[0][0][0];
564 564

  
565
      float x = q.get1();
566
      float y = q.get2();
567
      float z = q.get3();
568
      float w = q.get4();
565
      float x = q.get0();
566
      float y = q.get1();
567
      float z = q.get2();
568
      float w = q.get3();
569 569

  
570 570
      for(int i = 0; i< mSize; i++)
571 571
        for(int j = 0; j< mSize; j++)
......
575 575
              {
576 576
              q = mQuatScramble[i][j][k];
577 577

  
578
              if( q.get1()!=x || q.get2()!=y || q.get3()!=z || q.get4()!=w )
578
              if( q.get0()!=x || q.get1()!=y || q.get2()!=z || q.get3()!=w )
579 579
                {
580 580
                return false;
581 581
                }
......
610 610
      mRotAxis = vector;
611 611
      mRotRow  = row;
612 612

  
613
      mRotationAngleStatic.set1(0.0f);
613
      mRotationAngleStatic.set0(0.0f);
614 614

  
615 615
      for(int x=0; x<mSize; x++)
616 616
        for(int y=0; y<mSize; y++)
......
666 666

  
667 667
                  if( pointNum>=1 )
668 668
                    {
669
                    float startingAngle = mRotationAngle[x][y][z].getPoint(pointNum-1).get1();
669
                    float startingAngle = mRotationAngle[x][y][z].getPoint(pointNum-1).get0();
670 670
                    int nearestAngleInDegrees = computeNearestAngle(startingAngle);
671 671
                    double nearestAngleInRadians = nearestAngleInDegrees*Math.PI/180;
672 672
                    float sinA =-(float)Math.sin(nearestAngleInRadians*0.5);
......
687 687
                }
688 688
              }
689 689

  
690
      mRotationAngleStatic.set1(0);
690
      mRotationAngleStatic.set0(0);
691 691
      }
692 692
}

Also available in: Unified diff