• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Compute Latitude and Longitude 1 nm ahead (given heading)

Messages
126
Country
unitedstates
How do you Compute the Latitude and Longitude 1 nm ahead given the heading?

C# or c is my programming language. I can compute, distances and headings for position to position, but this must be some trig functions.

thanks, happy new year!
 
Here's an online caclulator.


You can use this to test your eventual calculations?

And the formula is here. You have to scroll down to the correct section, the top section is not what you want.


  • Let first point latitude be la1,
  • longitude as lo1,
  • d be distance,
  • R as radius of Earth,
  • Ad be the angular distance i.e d/R and
  • θ be the bearing,
Here is the formula to find the second point, when first point, bearing and distance is known:

  • latitude of second point = la2 = asin(sin la1 * cos Ad + cos la1 * sin Ad * cos θ), and
  • longitude of second point = lo2 = lo1 + atan2(sin θ * sin Ad * cos la1 , cos Ad – sin la1 * sin la2)

Hope this helps,
 
THANKS!

public (double newLatitude, double newLongitude) CalculateNewPosition(double latitude, double longitude, double heading, double distance)
{
const double EarthRadius = 3440.065; // Earth's radius in nautical miles

// Convert latitude, longitude, and heading to radians
double latRad = latitude * (Math.PI / 180);
double lonRad = longitude * (Math.PI / 180);
double headingRad = heading * (Math.PI / 180);

// Calculate new position
double newLatRad = Math.Asin(Math.Sin(latRad) * Math.Cos(distance / EarthRadius) +
Math.Cos(latRad) * Math.Sin(distance / EarthRadius) * Math.Cos(headingRad));
double newLonRad = lonRad + Math.Atan2(Math.Sin(headingRad) * Math.Sin(distance / EarthRadius) * Math.Cos(latRad),
Math.Cos(distance / EarthRadius) - Math.Sin(latRad) * Math.Sin(newLatRad));

// Convert new position back to degrees
double newLatitude = newLatRad * (180 / Math.PI);
double newLongitude = newLonRad * (180 / Math.PI);

return (newLatitude, newLongitude);
}
 
Last edited:
Tom provided links referring to great circle calculations that should be enough precise for small distances
If a more precise result is required (especially for longer distances), calculation based on the earth ellipsoid model (WGS84) would be more appropriate
A script from Chris Veness is available here (easily translatable in C language)
Ellipsoid calculation
Other useful scripts for the spherical model are also available here
Spherical model scripts

Hervé
 
Back
Top