-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
atan2 in std #141
Comments
I agree this is useful, and yes, your code is correct for that. local atan2(y, x) =
if x > 0 then
atan(y / x)
else if x < 0 && y >= 0 then
atan(y / x) + pi
else if x < 0 && y < 0 then
atan(y / x) - pi
else if x == 0 && y > 0 then
pi / 2
else if x == 0 && y < 0 then
-pi / 2
else
error "atan2(0, 0) is undefined"; But I agree this is acceptable to add this to standard library. The problem is, it should also be added to official jsonnet implementation... |
I also have nearly the same jsonnet atan2 code myself too, but it just seems better to be in std with all the other trig. I put a request in for the c++ library as well: |
It would be great to add atan2 to std. atan2 is super useful for converting from rectangular to polar coordinates.
I think it looks something like this, but ... I'm not expert with rust at all:
The text was updated successfully, but these errors were encountered: