def sincosd(x):
"""Compute sine and cosine of x in degrees."""
r = math.fmod(x, 360)
q = Math.nan if Math.isnan(r) else int(math.floor(r / 90 + 0.5))
r -= 90 * q; r = math.radians(r)
s = math.sin(r); c = math.cos(r)
q = q % 4
if q == 1:
s, c = c, -s
elif q == 2:
s, c = -s, -c
elif q == 3:
s, c = -c, s
# Remove the minus sign on -0.0 except for sin(-0.0).
# On Windows 32-bit with python 2.7, math.fmod(-0.0, 360) = +0.0
# (x, c) here fixes this bug. See also Math::sincosd in the C++ library.
# AngNormalize has a similar fix.
s, c = (x, c) if x == 0 else (0.0+s, 0.0+c)
return s, c
geomath.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录