The scala.math.atan2 function documentation could be improved

I’m looking at this page for the documentation of the scala.math.atan2 function. In my opinion the documentation has vital information missing. It would be great if this and all the inverse trig functions explain explicitly which angles they return. The function ought to say that the function returns a method between some angle and some angle. For example, between -pi and pi, or between 0 and 2*pi.

1 Like

Yes, that would be nice.

In the mean time, they’re just forwarders for which has more documentation, including this point (it’s -pi to pi)

1 Like

Yes, I see, and there’s also a see-also link on the scaladoc page.

I agree.

(although, isn’t -pi to pi kind of standard?)

But the atan2 case is even worse: the signature says it returns Double, but the comment implies it returns (Double, Double).

Not sure if there’s really a such thing as standard, mathematically speaking, for inverse trig functions.

Where do you see that it returns (Double,Double). The atan2 is special among the trig function in that it takes two doubles rather than just one Double as argument. The problem being that it returns the inverse tangent of the quotient of the given Doubles, but since division loses the individual signs, atan2 is useful to decide which quadrant is being referred to.

Converts rectangular coordinates (x, y) to polar (r, theta).

Oh, I see what you mean. It implies that atan2 returns (r,theta) which it certainly does not do.