【发布时间】:2017-11-04 02:49:42
【问题描述】:
Average of two angles with wrap around 中的最佳答案每次测试 + cmets 都是错误的。
底部答案 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 不同,这会产生不同的结果。
如何求圆中两个角的平均值?
编辑:尝试使用弧度。 度数分别为 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。
【问题讨论】:
-
尝试使用弧度。
-
我尝试使用弧度,请参阅编辑
-
使用
math:atan2(S,C)这会将角度放在正确的象限上。 -
这给出了数学:atan2(S, C)。 3.1288514248714483。 ~178 度
-
在
S=-0.9984044934712312和C=-1.002387709839821上面的代码中。atan2(S,C)=-2.35818是 -135 度。 -135+360=225
标签: erlang geometry trigonometry