为什么这个轴承计算如此疏散? [英] Why is this bearing calculation so inacurate?

查看:151
本文介绍了为什么这个轴承计算如此疏散?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

甚至不准确吗?我用Apfloat任意精度重新实现了整个事情,并且我开始时应该知道没有区别!!

Is it even that inaccurate? I re-implented the whole thing with Apfloat arbitrary precision and it made no difference which I should have known to start with!!

public static double bearing(LatLng latLng1, LatLng latLng2) {
 double deltaLong = toRadians(latLng2.longitude - latLng1.longitude);

 double lat1 = toRadians(latLng1.latitude);
 double lat2 = toRadians(latLng2.latitude);

 double y = sin(deltaLong) * cos(lat2);
 double x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(deltaLong);
 double result = toDegrees(atan2(y, x));
 return (result + 360.0) % 360.0;
}

@Test
 public void testBearing() {

  LatLng first = new LatLng(36.0, 174.0);
  LatLng second = new LatLng(36.0, 175.0);
  assertEquals(270.0, LatLng.bearing(second, first), 0.005);
  assertEquals(90.0, LatLng.bearing(first, second), 0.005);
 }

测试中的第一个断言给出了:

The first assertion in the test gives this:


java.lang.AssertionError:
expected:< 270.0>但
是:< 270.29389750911355>

java.lang.AssertionError: expected:<270.0> but was:<270.29389750911355>

0.29似乎还有很长的路要走?这是我选择实施的公式吗?

0.29 seems to quite a long way off? Is this the formula i chose to implement?

推荐答案

如果你已经完成了你所做的事并正确地完成了你已经从A到B的最短路径中找出了A的B轴承,在球面(ish)地球的表面上是A和B之间的大圆弧,而不是纬线之间的弧线。 A和B.

If you've done what you seem to have done and done it correctly you have figured out the bearing of A from B along the shortest route from A to B which, on the surface of the spherical (ish) Earth is the arc of the great circle between A and B, NOT the arc of the line of latitude between A and B.

Mathematica的大地测量函数为您的测试位置提供 89.7061 270.294

Mathematica's geodetic functions give the bearings, for your test positions, as 89.7061 and 270.294.

所以,看起来好像(a)你的计算是正确的但是(b)你的导航技能需要抛光。

So, it looks as if (a) your calculation is correct but (b) your navigational skills need polishing up.

这篇关于为什么这个轴承计算如此疏散?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆