The atan(a) is positive when a is positive, and negative otherwise, so the mentioned change in axes convention leads to the results you're obtaining (which are correct, supposing you're using in both images point 1 to be the one in the left side and point 2 the one in the right side, i.e. you're calculating the minimum angle between the line connecting both points and a virtual horizontal line passing through the point at the bottom).