# Calculate destination coordinate

Theory

Sometimes it’s useful to be able to calculate the coordinates of a destination based off a point of origin, a bearing (β) and a distance. One popular activity that uses this is orienteering. Orienteering is a competition which is a timed race where participants use a map, and a compass to navigate between check points. At each check point the participant will receive the bearing and distance to the next check point based on the current location of the check point. The distance that is used is the arc length (L) between the two points. Knowing this we can derive the central angle (δ) between the two points based at the center of the Earth.

Using the central angle and trigonometry we can calculate the latitude of the destination point using the following formula:

Now that we know the latitude of the destination point we can calculate the longitude by using the following formula:

Application

The function to calculate the destination coordinate will take in three parameters; a point of origin, a bearing, and a distance. With these parameters we can calculate the latitude and longitude coordinates of the destination point. This function returns a VELatLong object.

`var earthRadius = 6367; //radius in km`
```function calculateCoord(origin, brng, arcLength){
```    var lat2 = Math.asin( Math.sin(lat1)*Math.cos(centralAngle) + Math.cos(lat1)*Math.sin(centralAngle)*Math.cos(DegtoRad(brng)));
```    return new VELatLong(RadtoDeg(lat2),RadtoDeg(lon2));