I need help with a math issue:
I need to get the angle from 0 until 360 degrees but this code gives the angle between -90 until 90 degrees:
N = math.cos(β * (math.pi / 180)) * math.tan((f + ω) * (math.pi / 180))
N2 = math.atan(N) * (180 / math.pi)
I want to N2 change between 0 to 360 degrees.
Use atan2
like so
import math
math.atan2(-0.1, 0.1) + math.pi
The problem is atan
does not know which quadrant you are in, while atan2
does as it accepts an x and y coordinate as input.
If you compute atan(y / x)
you need to switch things around so you compute atan2(y, x)
instead. I can't understand how that relates to your example exactly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.