Is there a way to calculate angle between two Latitude/Longitude points?
What I am trying to achieve is to know where the user is heading. For example, user is head
Considering Nayanesh Gupte's answer and its comments. I've changed some part of the code and wrote it in PHP.
Here is the function:
function angleFromCoordinate($lat1, $long1, $lat2, $long2) {
$lat1 = deg2rad($lat1);
$lat2 = deg2rad($lat2);
$long1 = deg2rad($long1);
$long2 = deg2rad($long2);
$dLon = $long2 - $long1;
$y = sin($dLon) * cos($lat2);
$x = cos($lat1) * sin($lat2) - sin($lat1) * cos($lat2) * cos($dLon);
$brng = atan2($y, $x);
$brng = $brng * 180 / pi();
$brng = fmod($brng + 360, 360);
return $brng;
}