Una problema

Can anybody tell me what is wrong with this code?

      if (distance(ship.getShipNode(),world)<=190f) {
         if (ship.getInScene()) {
            float hgt = distance(ship.getShipNode(),world);
            // get old locations
            Vector3f oShip = ship.getWorldTranslation().clone();
            Vector3f oWorld = world.getWorldTranslation().clone();
            Vector3f rotVecShip1z = (ship.getShipNode().getWorldRotation().getRotationColumn(2, null)).normalize().clone();
            // attach ship to world and reset variables
            ship.setLocalRotation(new Quaternion(0,0,0,1));
            ship.getShipNode().setLocalRotation(new Quaternion(0,0,0,1));
            ship.updateGeometricState(interpolation, true);
            // rotate ship to reach old position   
            Vector3f mShip = ship.getShipNode().getWorldTranslation().clone();            
            Vector3f vec1 = oShip.subtract(oWorld).normalize();
            Vector3f vec2 = mShip.subtract(oWorld).normalize();
            Vector3f axis = vec2.cross(vec1).normalize();         
            float angBetween = vec1.angleBetween(vec2);
            Quaternion q1 = new Quaternion();
            q1.fromAngleNormalAxis(angBetween, axis);

            ship.updateGeometricState(interpolation, true);
            // rotate ship node to match impact rotation

            Vector3f rotVecShip2z = (ship.getShipNode().getWorldRotation().getRotationColumn(2, null)).normalize().clone();            
            Vector3f axisShip = rotVecShip2z.cross(rotVecShip1z).normalize().clone();         
            float angBetweenShip = rotVecShip2z.angleBetween(rotVecShip1z);

            Quaternion qShip = new Quaternion();
            qShip.fromAngleAxis(angBetweenShip, axisShip.mult(10f));
            ship.updateGeometricState(interpolation, true);

I have a spaceship flying around attached to the scene node and then here it approaches a planet and I attach the spaceship node to the world node instead (so that it moves as the world moves) ... so, I change the position of the spaceship node to match the position as it was when it was in the scene node (which works fine) ... but I also want to match the rotation of the ship as it was - and it ONLY works if I the ship has only rotated on the X axis (i.e. it will be positioned and rotated fine after attachment to the world node) ... if it has moved at all on any other axis it still positions correctly but the rotation is all wrong.

What I'm trying to do is to take the vector which the ship is pointing at initially and then take the vector after it has been repositioned on the world node and then rotating the ship by the angle between the vectors on an axis perpendicular to those vectors.

If anyone has any ideas it would be most appreciated as I seem to have hit a wall with this one!  :-o