The atan2 function is used mostly to convert from rectangular (x,y) to polar (r,theta) (r,th) coordinates that must satisfy x = r*cos theta r*costh and y = r*sin theta. r*sinth. These equations are satisfied when (x=0,y=0) is mapped to (r=0,theta=0).
(r=0,th=0). In general, conversions to polar coordinates should be computed thus:
r := hypot(x,y); ... := sqrt(x*x+y*y)
theta := atan2(y,x).
r := hypot(x,y); ... := v/(x20+y20)
th := atan2(y,x).