I am familiar with the formula to calculate the Great Circle Distance between two points.
i.e.
<?php
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
//convert degrees to distance depending on units desired
?>
What I need though, is the reverse of this. Given a starting point, a distance, and a simple cardinal NSEW direction, to calculate the position of the destination point. It's been a long time since I was in a math class. ;)
It would be harder to back out the Haversine fomula, then generate your own, I would think.
First the angle generated from the Earth core by traveling a "straight" line on the surface (you think it is straight, but it is curving).
Angle in Radians = Arc Length / radius. Angle = ArcLen/6371 km
Latitude should be easy, just the "vertical" (north/south) component of your angle.
Lat1 + Cos(bearing) * Angle
Longitude divisions vary by latitude. So that becomes harder. You would use:
Sin(bearing) * Angle (with East defined as negative) to find the angle in longitude direction, but converting back to actual longitude at that latitude would be more difficult.
To answer my own question just so it's here for anyone curious, a PHP class as converted from the C function provided by Chad Birch:
Here's a C implementation that I found, should be fairly straightforward to translate to PHP:
See the section Destination point given distance and bearing from start point at this website: http://www.movable-type.co.uk/scripts/latlong.html