Project

General

Profile

« Previous | Next » 

Revision 348dfe69

Added by Leszek Koltunski almost 5 years ago

Adjustment to Static's API.

View differences:

src/main/java/org/distorted/effect/solve/SolveEffectSpin.java
33 33
  {
34 34
  private static Static4D quatMultiply( Static4D quat1, Static4D quat2 )
35 35
    {
36
    float qx = quat1.get1();
37
    float qy = quat1.get2();
38
    float qz = quat1.get3();
39
    float qw = quat1.get4();
36
    float qx = quat1.get0();
37
    float qy = quat1.get1();
38
    float qz = quat1.get2();
39
    float qw = quat1.get3();
40 40

  
41
    float rx = quat2.get1();
42
    float ry = quat2.get2();
43
    float rz = quat2.get3();
44
    float rw = quat2.get4();
41
    float rx = quat2.get0();
42
    float ry = quat2.get1();
43
    float rz = quat2.get2();
44
    float rw = quat2.get3();
45 45

  
46 46
    float tx = rw*qx - rz*qy + ry*qz + rx*qw;
47 47
    float ty = rw*qy + rz*qx + ry*qw - rx*qz;
......
56 56

  
57 57
  private static Static4D rotateVectorByInvertedQuat(Static4D vector, Static4D quat)
58 58
    {
59
    float qx = quat.get1();
60
    float qy = quat.get2();
61
    float qz = quat.get3();
62
    float qw = quat.get4();
59
    float qx = quat.get0();
60
    float qy = quat.get1();
61
    float qz = quat.get2();
62
    float qw = quat.get3();
63 63

  
64 64
    Static4D quatInverted= new Static4D(-qx,-qy,-qz,qw);
65 65
    Static4D tmp = quatMultiply(quatInverted,vector);
......
78 78
    Static4D tmpAxis    = new Static4D(0,1,0,0);                          // vert axis no matter
79 79
    Static4D rotated    = rotateVectorByInvertedQuat(tmpAxis,quaternion); // how cube is rotated
80 80

  
81
    Static3D axis  = new Static3D(rotated.get1(), rotated.get2(), rotated.get3());
81
    Static3D axis  = new Static3D(rotated.get0(), rotated.get1(), rotated.get2());
82 82
    Static3D center= new Static3D(0,0,0);
83 83

  
84 84
    Dynamic1D d = new Dynamic1D(duration/2, 1.0f);
src/main/java/org/distorted/magic/RubikSurfaceView.java
73 73

  
74 74
    public static Static4D quatMultiply( Static4D quat1, Static4D quat2 )
75 75
      {
76
      float qx = quat1.get1();
77
      float qy = quat1.get2();
78
      float qz = quat1.get3();
79
      float qw = quat1.get4();
76
      float qx = quat1.get0();
77
      float qy = quat1.get1();
78
      float qz = quat1.get2();
79
      float qw = quat1.get3();
80 80

  
81
      float rx = quat2.get1();
82
      float ry = quat2.get2();
83
      float rz = quat2.get3();
84
      float rw = quat2.get4();
81
      float rx = quat2.get0();
82
      float ry = quat2.get1();
83
      float rz = quat2.get2();
84
      float rw = quat2.get3();
85 85

  
86 86
      float tx = rw*qx - rz*qy + ry*qz + rx*qw;
87 87
      float ty = rw*qy + rz*qx + ry*qw - rx*qz;
......
96 96

  
97 97
    public static Static4D rotateVectorByQuat(Static4D vector, Static4D quat)
98 98
      {
99
      float qx = quat.get1();
100
      float qy = quat.get2();
101
      float qz = quat.get3();
102
      float qw = quat.get4();
99
      float qx = quat.get0();
100
      float qy = quat.get1();
101
      float qz = quat.get2();
102
      float qw = quat.get3();
103 103

  
104 104
      Static4D quatInverted= new Static4D(-qx,-qy,-qz,qw);
105 105
      Static4D tmp = quatMultiply(quat,vector);
......
112 112

  
113 113
    public static Static4D rotateVectorByInvertedQuat(Static4D vector, Static4D quat)
114 114
      {
115
      float qx = quat.get1();
116
      float qy = quat.get2();
117
      float qz = quat.get3();
118
      float qw = quat.get4();
115
      float qx = quat.get0();
116
      float qy = quat.get1();
117
      float qz = quat.get2();
118
      float qw = quat.get3();
119 119

  
120 120
      Static4D quatInverted= new Static4D(-qx,-qy,-qz,qw);
121 121
      Static4D tmp = quatMultiply(quatInverted,vector);
......
393 393
                                           Static2D rot = mMovement.newRotation(rotatedTouchPoint2);
394 394
                                           RubikCube cube = mRenderer.getCube();
395 395

  
396
                                           cube.addNewRotation( (int)rot.get1(), (int)(cube.getSize()*rot.get2()) );
396
                                           cube.addNewRotation( (int)rot.get0(), (int)(cube.getSize()*rot.get1()) );
397 397

  
398 398
                                           mBeginningRotation = false;
399 399
                                           mContinuingRotation= true;
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
}
src/main/java/org/distorted/object/RubikCubeMovement.java
160 160
      {
161 161
      float cubeHalfSize= RubikCube.CUBE_SCREEN_RATIO*0.5f;
162 162

  
163
      mPoint[0]  = rotatedTouchPoint.get1();
164
      mPoint[1]  = rotatedTouchPoint.get2();
165
      mPoint[2]  = rotatedTouchPoint.get3();
163
      mPoint[0]  = rotatedTouchPoint.get0();
164
      mPoint[1]  = rotatedTouchPoint.get1();
165
      mPoint[2]  = rotatedTouchPoint.get2();
166 166

  
167
      mCamera[0] = rotatedCamera.get1();
168
      mCamera[1] = rotatedCamera.get2();
169
      mCamera[2] = rotatedCamera.get3();
167
      mCamera[0] = rotatedCamera.get0();
168
      mCamera[1] = rotatedCamera.get1();
169
      mCamera[2] = rotatedCamera.get2();
170 170

  
171 171
      for( mLastTouchedFace=FRONT; mLastTouchedFace<=BOTTOM; mLastTouchedFace++)
172 172
        {
......
192 192
      {
193 193
      float cubeHalfSize= RubikCube.CUBE_SCREEN_RATIO*0.5f;
194 194

  
195
      mPoint[0] = rotatedTouchPoint.get1();
196
      mPoint[1] = rotatedTouchPoint.get2();
197
      mPoint[2] = rotatedTouchPoint.get3();
195
      mPoint[0] = rotatedTouchPoint.get0();
196
      mPoint[1] = rotatedTouchPoint.get1();
197
      mPoint[2] = rotatedTouchPoint.get2();
198 198

  
199 199
      castTouchPointOntoFace(mLastTouchedFace,cubeHalfSize,mDiff);
200 200

  
......
218 218

  
219 219
    public float continueRotation(Static4D rotatedTouchPoint)
220 220
      {
221
      mDiff[0] = rotatedTouchPoint.get1()-mTouch[0];
222
      mDiff[1] = rotatedTouchPoint.get2()-mTouch[1];
223
      mDiff[2] = rotatedTouchPoint.get3()-mTouch[2];
221
      mDiff[0] = rotatedTouchPoint.get0()-mTouch[0];
222
      mDiff[1] = rotatedTouchPoint.get1()-mTouch[1];
223
      mDiff[2] = rotatedTouchPoint.get2()-mTouch[2];
224 224

  
225 225
      int xAxis= retFaceXaxis(mLastTouchedFace);
226 226
      int yAxis= retFaceYaxis(mLastTouchedFace);

Also available in: Unified diff