Hi ,
I have the coordinates from start (origin) and destination.
I wish them calculate the Course,Desired Track(DTK).
Ssomeone knows how calculated the course or as the case may be a C-program is available.
Thanks for any help.
Willy
Hi ,
I have the coordinates from start (origin) and destination.
I wish them calculate the Course,Desired Track(DTK).
Ssomeone knows how calculated the course or as the case may be a C-program is available.
Thanks for any help.
Willy
/*-----------------------------------------------------------------------------------------------**
** Calculate bearing to target from point. **
** Returns: bearing in degrees, inputs: current lat/lon, target lat/lon **
** NOTE: Math lib requires units to be in RADIANS
** Formula: **
** Bearing = atan2( sin(dLon).cos(lat2),cos(lat1).sin(lat2) - sin(lat1).cos(lat2).cos(d_long) ) **
** **
** y = sin(dLon) * cos(lat2); **
** x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2)* cos(dLon); **
** bearing = atan2(y, x); **
**-----------------------------------------------------------------------------------------------*/
double calcBearing(double CurrentLatitude, double CurrentLongitude, double SavedLatitude, double SavedLongitude)
{
double RadToDegrees = 57.2957795;
double DegToRadians = 0.017453293; // (PI/180) 0.017453293
double DeltaLongitude, x, y, Bearing; //
// degrees to radians
CurrentLatitude = (CurrentLatitude + 180) * DegToRadians; // Remove negative offset (0-360), convert to RADS
CurrentLongitude = (CurrentLongitude + 180) * DegToRadians;
SavedLatitude = (SavedLatitude + 180) * DegToRadians;
SavedLongitude = (SavedLongitude + 180) * DegToRadians;
//CurrentLatitude = CurrentLatitude * DegToRadians; // convert to RADS
//CurrentLongitude = CurrentLongitude * DegToRadians;
//SavedLatitude = SavedLatitude * DegToRadians;
//SavedLongitude = SavedLongitude * DegToRadians;
DeltaLongitude = SavedLongitude - CurrentLongitude;
y = sin(DeltaLongitude) * cos(SavedLatitude);
x = (cos(CurrentLatitude) * sin(SavedLatitude)) - (sin(CurrentLatitude) * cos(SavedLatitude)* cos(DeltaLongitude));
Bearing = atan2(y, x);
Bearing = Bearing + RadToDegrees;
return(Bearing);
}
*/