简体   繁体   English

在python中将度数映射到0 - 360

[英]map degrees to 0 - 360 in python

is it possible to map a value of rotation to be inside the range of 0-360 degrees? 是否可以将旋转值映射到0-360度范围内?

For example: 例如:

  • a angle of -10° should be 350° -10°的角度应为350°
  • a angle of 760° should be 40° degrees? 760°的角度应该是40°?

Is there an easy solution? 有一个简单的解决方案吗? Maybe in mathutils? 也许在mathutils?

best, chris 最好,克里斯

You can use the modulo operator % for this: 您可以使用模数运算符%

>>> print -10 % 360
350
>>> print 760 % 360
40

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM