First parameter must be y and the second is x.
double atan2(double y, double x)
Atan2 is actually specified arctangent function of y/x
Because of that usually first parameter is taken y.
Also you can get proper degree sometimes when you swap x and y because in some borders like x<0 and y<0 it doesn't matter swapped or not.