I’ve been working on a new iOS project that uses CoreLocation to determine some points. While CLLocation has a method for determining the distance between two locations (distanceFromLocation:
) it doesn’t have one for doing the opposite: calculating a second location based on a distance (and bearing) from the first.
So I added a category on CLLocation that performs this calculation:
1 2 3 4 5 6 |
|
The other need I had was to calculate the bearing between two points:
1 2 3 4 5 6 7 |
|
Both of these calculations use the formulas provided on the page Calculate distance, bearing and more between Latitude/Longitude points. This page has lots of information on the formulas and provides them in mathematical notation as well as examples translated to Javascript.
My Objective-C category incorporating these calculations is available from my Github account.