我很难将头部缠绕在一些三角函数上.我试图从开始lat和日志以及距离和方位推导出目的地纬度和经度.
幸运的是,我找到了一个惊人的网站,它描述了我需要的功能:http: //www.movable-type.co.uk/scripts/latlong.html "目的地点给定距离并从起点开始"我在我的尝试中java程序,但它不适合我.我按照网站的说法部署了它.这是我的代码:
double dist = 150/6371;
double brng = Math.toRadians(90);
double lat1 = Math.toRadians(26.88288045572338);
double lon1 = Math.toRadians(75.78369140625);
double lat2 = Math.asin( Math.sin(lat1)*Math.cos(dist) + Math.cos(lat1)*Math.sin(dist)*Math.cos(brng) );
double a = Math.atan2(Math.sin(brng)*Math.sin(dist)*Math.cos(lat1), Math.cos(dist)-Math.sin(lat1)*Math.sin(lat2));
System.out.println("a = " + a);
double lon2 = lon1 + a;
lon2 = (lon2+ 3*Math.PI) % (2*Math.PI) - Math.PI;
System.out.println("Latitude = "+Math.toDegrees(lat2)+"\nLongitude = "+Math.toDegrees(lon2));
Run Code Online (Sandbox Code Playgroud)
但它显示输出是:
a = 0.0
Latitude = 26.882880455723377
Longitude = 75.78369140625
Run Code Online (Sandbox Code Playgroud)
我没有得到我在做错的地方.请任何人帮我解决问题.
Thanx提前.:-)
java ×1