360 度环绕的 2 个角度的平均值

Average of 2 angles with 360 degrees wrap around

根据测试和评论,Average of two angles with wrap around 中的最佳答案是错误的。

最下面的回答12>

 math:atan(  (math:sin(180)+math:sin(270)) / (math:cos(180)+math:cos(270))).
-1.1946710584651132

但我得到 -1.946.. 而不是预期的 225.

Erlang 的 math:atan 不符合 http://rapidtables.com/calc/math/Arctan_Calculator.htm 的行为,但是,这会给出不同的结果。

如何求圆内 2 个角的平均值?

编辑:正在尝试使用弧度。 度数为 180 和 270。

16> A = 180 * 3.14 / 180.
3.14
17> B = 270 * 3.14 / 180.
4.71
18> S = math:sin(A) + math:sin(B).
-0.9984044934712312
19> S2 = S / 2.
-0.4992022467356156
20> C = math:cos(A) + math:cos(B).
-1.002387709839821
21> C2 = C / 2.
-0.5011938549199105
22> math:atan(S, C).
** exception error: undefined function math:atan/2
23> math:atan(S/C).
0.7834073464102068
24> math:atan(S/C) * 180 / 3.14.
44.90870138657236
25> math:atan(S2/C2) * 180 / 3.14.
44.90870138657236

转换: -1.19 度 = -68.18198.3 360 - 68 = 292。这不是预期的 225。

<cos(t), sin(t)> 是角度为 t 弧度 的单位向量。因此,您的公式将两个单位向量相加,然后求出所得向量的角度。

只需使用弧度而不是度数,并使用 atan2 而不是 atan(将角度放在正确的象限上),您应该会看到您的公式正确运行。

math:atan2( math:sin(t1)+math:sin(t2), math:cos(t1)+math:cos(t2))

如果两个角度恰好相差 180 度,则此公式不起作用。在这种情况下,合成向量是零向量,atan 未定义。