I cannot seem to find a solution to my math problem in Python, no article fits the issue. Do believe it may resides in a structural setup, but frankly I am out of options based on my knowledge. Have tried to read the library, but it too does not provide an solution.
Simply what is happening is this:
Code runs fine, except the output is wrong.
import math
descent_speed = float(150 * (1/60) * 6080 * (math.tan(3.0)))
print(descent_speed)
Results: -2166.7074547290226
Now the correct answer to the calculation of
150 = Ground Speed in knots 3.0 = Angle of descent path in degrees
150 * 1/60 * 6080 * tan(3.0) = 796.5982451
That is according to the calculator which equals to 797 feet per minute.
Now I did try adding 3.0 as a degree using math.degrees, but that did not work.
import math
GS = 150
slope = math.degrees(3.0)
descent_speed = float((GS) * (1/60) * 6080 * (math.tan(slope))) #code to calculate descent speed based on descent angle
print(descent_speed)
Results: -19164.534008140585
So please help, I am out of ideas?
Trigonometric functions take their inputs in radians. Change math.degrees
to math.radians
:
>>> help(math.tan)
Help on built-in function tan in module math:
tan(x, /)
Return the tangent of x (measured in radians).
>>> angle_in_degrees = 3.0
>>> 150 * (1/60) * 6080 * math.tan(math.radians(angle_in_degrees))
796.5982451022264
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.