我就废话不多说了,还是直接看代码吧!
import math
def deal(yaw):
if(yaw<0):
print(-(abs(yaw)/math.pi)*180)
print(math.degrees(yaw))
else:
print((abs(yaw)/math.pi)*180)
print(math.degrees(yaw))
yaw=math.pi/6
deal(yaw)
yaw=-math.pi/3
deal(yaw)
输出
30.0
29.999999999999996
-60.0
-59.99999999999999
补充知识:MATLAB中角度转换成弧度函数――degtorad
degtorad
Convert angles from degrees to radians
将角度从度数转换为弧度
Syntax:angleInRadians = degtorad(angleInDegrees)
语法:弧度 = degtorad(角度)
Description
angleInRadians = degtorad(angleInDegrees) converts angle units from degrees to radians. This is both an angle conversion function and a distance conversion function, since arc length can be a measure of distance in either radians or