# Calculate the target point by using initial coordinate, bearing angle and distance

I need to calculate the target coordinate by using the initial coordinate, bearing angle and distance. I came across this on how to calculate it. Then I construct the code in C#, but it seems I can't get exact location correctly. I use below code this my answer:

``````Target latitude :6.34374176458679
Target longitude : 206.297566445544
``````

When I use the application from the website i mention it get this:

``````Destination point:  03° 10′ 28″ N, 103° 08′ 15″ E /Lat:3.174444° Lon:103.150833°
Final bearing:  040° 24′ 37″
``````

That are most accurate. Has anybody used this kind of method?

EDIT:

``````        //bearing angle

double angDist = 0.717 / 6371;

Console.WriteLine("Angular distance:" + angDist);

double latitude =  3.169416;
double longitude = 103.146690;

latitude *= Math.PI / 180;
longitude *= Math.PI / 180;

double forAtana = Math.Sin(rad) * Math.Sin(angDist) * Math.Cos(latitude);
double forAtanb = Math.Cos(angDist)-Math.Sin(latitude)*Math.Sin(lat2);

double lon2 = longitude + Math.Atan2(forAtana,forAtanb);

double finalLat = latitude + lat2;
double finalLon = longitude + lon2;

finalLat *=  180 / Math.PI;
finalLon *=  180 / Math.PI;

Console.WriteLine("Target latitude :" + finalLat);

Console.WriteLine("Target longitude : " + finalLon);

// supposely final answer should be Lat:3.174444° Lon:103.150833° (using the movable-type website)

``````
• Your code is using 6378137 (ellipsoid semi-major axis), not 6371000 (sphere radius). Feb 20 '19 at 18:13
• @mkennedy i edit the code using 6371 km (sphere radius) but still i dont get the same value as i the application on this website. Feb 21 '19 at 2:16

I think that you are adding `lat1` (decimal degrees) + `lat2` (radians).

`lat2` and `lon2` are final latitude and longitude in radians. Just convert them to degrees.

UPDATE: I don't know the language, but must to be something like:

``````double finalLat = lat2 * 180 / Math.PI;
double finalLon = lon2 * 180 / Math.PI;

Console.WriteLine("Target latitude : " + finalLat);
Console.WriteLine("Target longitude : " + finalLon);
``````

(Also, they are using `Radius = 6371 km`.)

• I just correct the comment you give. I use radius 6371 km, but it still not get the exact target coordinate. I get this result Target latitude :6.34374176458679 Target longitude : 206.297566445544. Feb 20 '19 at 8:04
• I just update my answer to be a bit more explicit. Feb 20 '19 at 10:11
• i already edit my code, but the final lat/lon value still far from the result i got using the application on this website. Feb 21 '19 at 2:18
• Because you are adding them, don't add. `lat2` is the final latitude. `lon2` is the final longitude. Feb 21 '19 at 2:19
• Thank you very much sir, i get the target coordinate. Feb 21 '19 at 2:33

This final code that will get the target point by using initial coordinate, bearing angle to target point and distance. I get this reference from this website.

``````        double rad = 64.10;

double angDist = 0.343 / 6371;

Console.WriteLine("Angular distance:" + angDist);

double latitude =   3.170620;
double longitude = 103.151279;

latitude *= Math.PI / 180;
longitude *= Math.PI / 180;

double forAtana = Math.Sin(rad) * Math.Sin(angDist) * Math.Cos(latitude);
double forAtanb = Math.Cos(angDist)-Math.Sin(latitude)*Math.Sin(lat2);

double lon2 = longitude + Math.Atan2(forAtana,forAtanb);

//double finalLat = latitude + lat2;
//double finalLon = longitude + lon2;

lat2 *=  180 / Math.PI;
lon2 *=  180 / Math.PI;

Console.WriteLine("Target latitude :" + lat2);

Console.WriteLine("Target longitude : " + lon2);