private static int getRelativeRotation(final int currentRot, final int targetRot) {
        int adjustedTargetRot = targetRot;
        while (adjustedTargetRot - currentRot > 180) {
            adjustedTargetRot -= 360;
        }
        while (adjustedTargetRot - currentRot < -180) {
            adjustedTargetRot += 360;
        }
        return adjustedTargetRot - currentRot;
    }
calculates a Relative rotation such that rotating from current to target is minimal
main/src/main/java/cgeo/geocaching/utils/ViewOrientation.java