[Solved] The arguments of atan2 in the document are in the wrong order. Should be atan2(y,x) not atan2(x,y)