Revision 348dfe69
Added by Leszek Koltunski over 4 years ago
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; |
Also available in: Unified diff
Adjustment to Static's API.