Quaternion rotation do not works as excepted
===

In OpenGL ES 1 for android, I have a Rubic cube that consists of 27 smaller cubes. i want rotations which cause particular small cube becoming exactly in front of the viewpoint. so I need two vectors. one is the vector that comes from the origin of the object to a particular cube. and another is the vector that comes from origin to the viewpoint. then the cross product of them gives me the axis of the rotation and the dot product gives me the angle.

I convert the (0,0,1) -which is the vector that comes from the origin to the viewpoint in world coordinate- to object coordinates. here is the code:

        matrixGrabber.getCurrentModelView(gl);
		temporaryMatrix.set(matrixGrabber.mModelView);

		inputVector[0] = 0f; 
		inputVector[1] = 0f;
		inputVector[2] = 1f;
		inputVector[3] = 1f;
		Matrix.multiplyMV(resultVector, 0, temporaryMatrix.InvertMatrix(), 0, inputVector,0);
		resultVector[0]/=resultVector[3];
		resultVector[1]/=resultVector[3];
		resultVector[2]/=resultVector[3];
                
        inputVector = ..... // appropriate vector due to user-selection 
        
        axis = Vector.normalized(Vector.crossProduct(Vector.normalized(inputVector), Vector.normalized(resultVector)));
	    degree = (float)Math.toDegrees(Math.acos(Vector.dot(Vector.normalized(inputVector), Vector.normalized(resultVector))));
						

I use two Quaternions for rotations. each time user choose an action one of that rotations should happen. here is the code :

        Quaternion currentRotation = new Quaternion();
		Quaternion temporaryRotation = new Quaternion();
        .
        .
        .
         currentRotation = (currentRotation).mulLeft(temporaryRotation.set(axis, degree));
         currentRotation.toMatrix(matrix);
         gl.glMatrixMode(GL10.GL_MODELVIEW);
	     gl.glMultMatrixf(matrix, 0);

now the problem is that it just works fine for the first rotation. whatever the first rotation would be. it works well but for the next rotations it seems that it gets wrong axis and degree. for example if user choose action "A" for first rotation it works fine as well as if user choose "B" for first rotation. but for next rotations it works not as excepted.