Hello Everybody,

I’ve been breaking my head over this problem:

I am making a rubik’s cube and want users to be able to solve it by clicking and dragging.

At this point i am as far that I can ‘pick’ a cube and drag ‘up’,‘down’,‘left’,‘right’.

When I do this, the algoritm will know which cube has been picked and which direction it wants to go.

All 8 cubes adjacent to it will turn also in the same rotation.

My problem is that I can only rotate one Axes, for example the Z-axes.

When I then rotate over the Y-axes I can make two things happen:

- the cubes that have been rotated over a different axe will rotate perfectly over the new axe, the cubes that haven’t been rotated yet will rotate very weard.
- the cubes that have not been rotated over a different axe will rotate perfectly over the new axe, the cubes that have been rotated already will rotate very weard.

Am I missing something about the quaternion rules?

Rubiks class:

[java]private void rotate(int curX, int curY, int curZ, int direction)

{

if(direction == Data.EAST)

for(int x = 0; x < 3; x++)

for(int z = 0; z < 3; z++)

cube[x][curY][z].rot(Vector3f.UNIT_Y,-1);

```
if(direction == Data.WEST)
for(int x = 0; x < 3; x++)
for(int z = 0; z < 3; z++)
cube[x][curY][z].rot(Vector3f.UNIT_Y,1);
if(direction == Data.NORTH)
for(int x = 0; x < 3; x++)
for(int y = 0; y < 3; y++)
{
cube[x][y][curZ].rot(Vector3f.UNIT_Z,1);
}
if(direction == Data.SOUTH)
for(int x = 0; x < 3; x++)
for(int y = 0; y < 3; y++)
{
cube[x][y][curZ].rot(Vector3f.UNIT_Z,-1);
}
}[/java]
```

Cube class:

[java]public void rot(Vector3f rot, int direction)

{

Quaternion quat = new Quaternion();

quat.fromAngleAxis(direction * FastMath.HALF_PI/16,rot);

```
this.setLocalRotation(this.getLocalRotation().mult(quat));
}[/java]
```