I'm no expert on ATAN2, because it's a rather tricky trig function to understand. (Its wikipedia page is hundreds of lines long.) The KM function for ATAN2 returns value correctly for all four quadrants as per its mathematical requirements. But the KM documentation describes it incorrectly: "For arguments x,y, not both zero, this function returns the angle in radians between the x-axis and the point (x,y)." If this was true, then the result of ATAN2(1,-1) should return a value representing the fourth quadrant because the point 1,-1 is in the fourth quadrant. Instead, it gives a result in the second quadrant. Similarly the result of ATAN2(-1,1) is in the fourth quadrant rather than the second. There is nothing wrong with the KM ATAN2 function, it works as it should. The problem is the documentation isn't correct.

Indeed, what I need is a function that "returns the angle in radians between the x-axis and the point (x,y)". If such a function existed, I would use it a lot. As ATAN2 doesn't do that, I have to write lots of code to patch up how it actually works. It's messy.

In my opinion, this is a perfect example of why functions would be great for KM. As it stands now I have to write my messy patch code every time I try to use ATAN2.