Atan function not working correctly?

i am trying the inverse tangent function in processing java,
i am using the atan(float) function,
when i use a paramater around 100 / 70 i am getting the wrong result,
this is true for atan(100 / 75), atan(100 / 80) and so on…
converted to degrees, it always returns 45 degrees, which it does not on the windows calculator.

am i doing something wrong or is this not the function i am looking for when needing an inverse tangent?
thanks in advance

1 Like

Try out atan(100 / 75.0) & atan(100.0 / 80) instead, so it’s not integer division anymore! :bulb:

2 Likes

Thank you very much for this, rookie mistake!

I still make that mistake every so often but catch them. :slight_smile:

There is also an atan2()

atan()
https://processing.org/reference/atan_.html

atan2()
https://processing.org/reference/atan2_.html
https://processing.org/examples/arctangent.html

Try this:

println(atan2(100, 75));  //You are still passing a float. See references.
println(atan(100.0/75));
2 Likes