**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 lat1 = DegtoRad(origin.Latitude);
var lon1 = DegtoRad(origin.Longitude);
var centralAngle = arcLength /earthRadius;

var lat2 = Math.asin( Math.sin(lat1)*Math.cos(centralAngle) + Math.cos(lat1)*Math.sin(centralAngle)*Math.cos(DegtoRad(brng)));
var lon2 = lon1+ Math.atan2(Math.sin(DegToRad(brng))*Math.sin(centralAngle)*Math.cos(lat1),Math.cos(centralAngle)-Math.sin(lat1)*Math.sin(lat2));

return new VELatLong(RadtoDeg(lat2),RadtoDeg(lon2));
}

Listing 1 Function to calculate a destination coordinate

The following post has additional information on the RadToDeg and DegToRad methods: http://rbrundritt.spaces.live.com/blog/cns!E7DBA9A4BFD458C5!257.entry

### Like this:

Like Loading...