我正在嘗試使用下面的dest()
函數來計算地球上的目標距離。但是,我的功能打印目標點(61.488580, 23.784896)
這是從初始點(61.488414, 23.784976)
僅0.018公里。正確的答案應該是(61.49806, 23.765)
。嘗試計算目標地球緯度和經度在地球上的問題
有人可以幫我找出我做錯了什麼嗎?
Source for how I calculate a destination point on the globe
lat2 = asin(sin(lat1)*cos(d/R) + cos(lat1)*sin(d/R)*cos(br))
lon2 = lon1 + atan2(sin(θ)*sin(d/R)*cos(lat1), cos(d/R)−sin(lat1)*sin(lat2))
這裏是我的出發點:
lat1= 61.488414 (degree)
lon1= 23.784976 (degree)
br= 315 (degree)
d= 1.5 (km)
R= 6371 (km)
lat2= ? (degree)
lon2= ? (degree)
這是我實現以下功能:
void dest(){
double lat1, lon1, lat2, lon2, x, y, R, d, br;
double lat1rad, lat2rad, lon1rad, dbyRrad, brrad;
lat1=61.488414;
lon1=23.784976;
br=315;
d=1.5;
R=6371;
lat1rad=Math.toRadians(lat1);
lat2rad=Math.toRadians(lat2);
lon1rad=Math.toRadians(lon1);
dbyRrad=Math.toRadians(d/R);
brrad=Math.toRadians(br);
lat2 = Math.asin(Math.sin(lat1rad)*Math.cos(dbyRrad)
+Math.cos(lat1rad)*Math.sin(dbyRrad)*Math.cos(brrad));
lat2=Math.toDegrees(lat2);
y=Math.sin(brrad)*Math.sin(dbyRrad)*Math.cos(lat1rad);
x=Math.cos(dbyRrad)-Math.sin(lat1rad)*Math.sin(lat2rad);
lon2 = Math.atan2(y,x);
lon2 = Math.toDegrees(lon2);
lon2 = lon1 + lon2;
System.out.println("lat2 = "+ lat2); // correct lat2= 61.49806, lon2=23.765
System.out.println("lon2 = "+ lon2);
}
是的,現在的作品!非常感謝.. – abtmp 2012-04-04 15:23:49