Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (float)getHeadingForDirectionFromCoordinate:(CLLocationCoordinate2D)fromLoc toCoordinate:(CLLocationCoordinate2D)toLoc
- {
- float fLat = degreesToRadians(fromLoc.latitude);
- float fLng = degreesToRadians(fromLoc.longitude);
- float tLat = degreesToRadians(toLoc.latitude);
- float tLng = degreesToRadians(toLoc.longitude);
- float degree = radiansToDegrees(atan2(sin(tLng-fLng)*cos(tLat), cos(fLat)*sin(tLat)-sin(fLat)*cos(tLat)*cos(tLng-fLng)));
- if (degree >= -180 && degree < 180)
- {
- return degree;
- }
- else if (degree >= 180 && degree < 360){
- return degree - 360;
- }
- else {
- return degree + 360;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement