110 |
110 |
return ret;
|
111 |
111 |
}
|
112 |
112 |
|
113 |
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
114 |
|
|
115 |
|
private void modifyCurrentPosition(Static4D quat)
|
116 |
|
{
|
117 |
|
float cubitCenterX = mCurrentPosition.get0();
|
118 |
|
float cubitCenterY = mCurrentPosition.get1();
|
119 |
|
float cubitCenterZ = mCurrentPosition.get2();
|
120 |
|
|
121 |
|
Static4D cubitCenter = new Static4D(cubitCenterX, cubitCenterY, cubitCenterZ, 0);
|
122 |
|
Static4D rotatedCenter = RubikSurfaceView.rotateVectorByQuat( cubitCenter, quat);
|
123 |
|
|
124 |
|
float rotatedX = rotatedCenter.get0();
|
125 |
|
float rotatedY = rotatedCenter.get1();
|
126 |
|
float rotatedZ = rotatedCenter.get2();
|
127 |
|
|
128 |
|
mCurrentPosition.set(rotatedX, rotatedY, rotatedZ);
|
129 |
|
mParent.clampPos(mCurrentPosition);
|
130 |
|
|
131 |
|
computeRotationRow();
|
132 |
|
}
|
133 |
|
|
134 |
113 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
135 |
114 |
// cast current position on axis; use mStart and mStep to compute the rotation row for each axis.
|
136 |
115 |
|
... | ... | |
157 |
136 |
return mOrigPosition;
|
158 |
137 |
}
|
159 |
138 |
|
|
139 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
140 |
|
|
141 |
void modifyCurrentPosition(Static4D quat)
|
|
142 |
{
|
|
143 |
float cubitCenterX = mCurrentPosition.get0();
|
|
144 |
float cubitCenterY = mCurrentPosition.get1();
|
|
145 |
float cubitCenterZ = mCurrentPosition.get2();
|
|
146 |
|
|
147 |
Static4D cubitCenter = new Static4D(cubitCenterX, cubitCenterY, cubitCenterZ, 0);
|
|
148 |
Static4D rotatedCenter = RubikSurfaceView.rotateVectorByQuat( cubitCenter, quat);
|
|
149 |
|
|
150 |
float rotatedX = rotatedCenter.get0();
|
|
151 |
float rotatedY = rotatedCenter.get1();
|
|
152 |
float rotatedZ = rotatedCenter.get2();
|
|
153 |
|
|
154 |
mCurrentPosition.set(rotatedX, rotatedY, rotatedZ);
|
|
155 |
mParent.clampPos(mCurrentPosition);
|
|
156 |
|
|
157 |
computeRotationRow();
|
|
158 |
}
|
|
159 |
|
160 |
160 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
161 |
161 |
|
162 |
162 |
int computeAssociation()
|
... | ... | |
187 |
187 |
{
|
188 |
188 |
String number = mOrigPosition.get0()+"_"+mOrigPosition.get1()+"_"+mOrigPosition.get2();
|
189 |
189 |
mQuatIndex = preferences.getInt("q_"+number, 0);
|
190 |
|
modifyCurrentPosition(mParent.QUATS[mQuatIndex]);
|
191 |
190 |
|
192 |
|
return mQuatIndex;
|
|
191 |
if( mQuatIndex < mParent.QUATS.length )
|
|
192 |
{
|
|
193 |
modifyCurrentPosition(mParent.QUATS[mQuatIndex]);
|
|
194 |
return mQuatIndex;
|
|
195 |
}
|
|
196 |
|
|
197 |
return -1;
|
193 |
198 |
}
|
194 |
199 |
|
195 |
200 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
Work around a rare crash on startup