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!
2 Likes
Thank you very much for this, rookie mistake!
glv
August 12, 2019, 11:39pm
4
I still make that mistake every so often but catch them.
There is also an atan2()
atan()
https://processing.org/reference/atan_.html
In mathematics, the inverse trigonometric functions (occasionally also called arcus functions, antitrigonometric functions or cyclometric functions) are the inverse functions of the trigonometric functions (with suitably restricted domains). Specifically, they are the inverses of the sine, cosine, tangent, cotangent, secant, and cosecant functions, and are used to obtain an angle from any of the angle's trigonometric ratios. Inverse trigonometric functions are widely us There are several notation...
atan2()
https://processing.org/reference/atan2_.html
https://processing.org/examples/arctangent.html
The function
atan2
(
y
,
x
)
{\displaystyle \operatorname {atan2} (y,x)}
or
arctan2
(
y
,
x
)
{\displaystyle \operatorname {arctan2} (y,x)}
(from "2-argument arctangent") is defined as the angle in the Euclidean plane, given in radians, between the positive x-axis and the ray to the point (x,y) ≠ (0,0).
The ...
Try this:
println(atan2(100, 75)); //You are still passing a float. See references.
println(atan(100.0/75));
2 Likes