I'm trying to find the angle made by the line joining a point with the x-axis with the x-axis. So in effect I'm trying to find plain old tan inverse. Here's the code I'm using in Python 3
angle_with_x_axis = math.atan(y_from_centre / x_from_centre)
I'm feeding in the point(1,1)
as y_from_centre
and x_from_centre
and I get
0.7853981633974483
My expected result is 45, but naturally. What am I doing wrong here?
The math. atan() method returns the arc tangent of a number (x) as a numeric value between -PI/2 and PI/2 radians. Arc tangent is also defined as an inverse tangent function of x, where x is the value of the arc tangent is to be calculated.
The value of arctan 2 is 63.435 degrees (or) 1.107 radians. We know that the angle in degrees can be converted into radians by multiplying it by π/180 and the angle in radians can be converted into degrees by multiplying it by 180/π.
math
uses radians. For degrees use math.degrees
:
>>> math.degrees(math.atan(1))
45.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With