Problems trying to calculate a destination Latitude and Longitude on a globe
<p>I'm trying to calcuate the a destination distance on a globe using the <code>dest()</code> function below. However my function prints the destination point <code>(61.488580, 23.784896 )</code> which is only 0.018km away from initial point <code>(61.488414, 23.784976)</code>. The correct answer should be <code>(61.49806, 23.765)</code>.</p>

<p>Can someone please help me figure out what I did wrong?</p>

<p><a href="http://www.catalina-capri-25s.org/tech/latlongcalc.asp" rel="nofollow">Source for how I calculate a destination point on the globe</a> </p>

<pre><code>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) )
</code></pre>

<p>Here are my starting points: </p>

<pre><code>lat1= 61.488414 (degree) 
lon1= 23.784976 (degree)  
br= 315 (degree)  
d= 1.5 (km)  
R= 6371 (km)  
lat2= ? (degree)  
lon2= ? (degree)
</code></pre>

<p>Here is my implementation of the following function:  </p>

<pre><code>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);
}               
</code></pre>
