Revision 49f67f9b
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/object/Cubit.java | ||
---|---|---|
124 | 124 |
|
125 | 125 |
private int computeNearestAngle(float angle) |
126 | 126 |
{ |
127 |
final int NEAREST = 90;
|
|
127 |
final int NEAREST = 360/mParent.getBasicAngle();
|
|
128 | 128 |
|
129 | 129 |
int tmp = (int)((angle+NEAREST/2)/NEAREST); |
130 | 130 |
if( angle< -(NEAREST*0.5) ) tmp-=1; |
... | ... | |
136 | 136 |
|
137 | 137 |
private void modifyCurrentPosition(Static3D currentPosition, Static4D quat) |
138 | 138 |
{ |
139 |
float diff = 0.5f*(mParent.mSize-1); |
|
140 |
float cubitCenterX = currentPosition.get0() - diff; |
|
141 |
float cubitCenterY = currentPosition.get1() - diff; |
|
142 |
float cubitCenterZ = currentPosition.get2() - diff; |
|
139 |
float cubitCenterX = currentPosition.get0(); |
|
140 |
float cubitCenterY = currentPosition.get1(); |
|
141 |
float cubitCenterZ = currentPosition.get2(); |
|
143 | 142 |
|
144 | 143 |
Static4D cubitCenter = new Static4D(cubitCenterX, cubitCenterY, cubitCenterZ, 0); |
145 | 144 |
Static4D rotatedCenter = RubikSurfaceView.rotateVectorByQuat( cubitCenter, quat); |
146 | 145 |
|
147 |
float rotatedX = rotatedCenter.get0() + diff;
|
|
148 |
float rotatedY = rotatedCenter.get1() + diff;
|
|
149 |
float rotatedZ = rotatedCenter.get2() + diff;
|
|
146 |
float rotatedX = rotatedCenter.get0(); |
|
147 |
float rotatedY = rotatedCenter.get1(); |
|
148 |
float rotatedZ = rotatedCenter.get2(); |
|
150 | 149 |
|
151 |
int roundedX = (int)(rotatedX+0.1f); |
|
152 |
int roundedY = (int)(rotatedY+0.1f); |
|
153 |
int roundedZ = (int)(rotatedZ+0.1f); |
|
150 |
currentPosition.set(rotatedX, rotatedY, rotatedZ); |
|
151 |
mParent.clampPos(currentPosition); |
|
154 | 152 |
|
155 |
currentPosition.set(roundedX, roundedY, roundedZ); |
|
156 | 153 |
computeRotationRow(); |
157 | 154 |
} |
158 | 155 |
|
... | ... | |
184 | 181 |
float y = position.get1(); |
185 | 182 |
float z = position.get2(); |
186 | 183 |
|
187 |
float nc = parent.mSize*0.5f; |
|
188 |
Static3D vector = new Static3D(x-nc+0.5f, y-nc+0.5f, z-nc+0.5f); |
|
184 |
Static3D vector = new Static3D(x,y,z); |
|
189 | 185 |
|
190 | 186 |
mParent = parent; |
191 | 187 |
mMesh = mesh; |
Also available in: Unified diff
Progress with Pyraminx.