数学公式中的 mod 代表什么并使用它 python

what is the mod in math formula stand for and using it python

我想使用这个公式来计算 python 中两个地理编码点之间的角度:

公式:

 tc1 = mod(atan2(sin(lon1 - lon2) * cos(lat2),
       cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(lon1-lon2)),
       2 * pi)

我的代码:

 tc1 = (atan2(sin(self.gdt1[1] - self.target_area[1]) * cos(self.target_area[1]),
                     cos(self.gdt1[0]) * sin(self.gdt1[0]) - sin(self.target_area[0]) * cos(
                         self.gdt1[1] - self.target_area[1])), 2 * pi)

mod代表什么,在python中如何表示(不可能是modulo吧?) 以及如何测试输出是否正确?

modmathematical modulo function(第一个参数除以第二个参数后的余数)- 在 Python 中,这由 % 运算符表示。下面的函数是等价的:

tc1 = atan2(sin(self.gdt1[1] - self.target_area[1]) * cos(self.target_area[1]), cos(self.gdt1[0]) * sin(self.gdt1[0]) - sin(self.target_area[0]) *cos(self.gdt1[1] - self.target_area[1])) % 2*pi

在你的函数中,这是有道理的,因为超过 2*pi 弧度(一个完整的圆)的任何角度都等于你减去 2*pi 弧度时的角度。

例如,3*pi 弧度在角度 方向 中等同于 1*pi 弧度。 (540度等于180度的方向)