File Exchange

image thumbnail

VRECKON: Find the endpoint of a geodesic on the ellipsoidal earth

version (2.03 KB) by Michael Kleder
Obtains a final location on ellipsoidal earth, given a start point, an azimuth and a distance.


Updated 13 Nov 2007

No License

This function uses the Vincenty direct algorithm to solve the "forward geodesic problem," which is the problem of computing the endpoint of a geodesic (shortest-distance) path on the ellipsoidal earth, given the start point, a path length, and a starting azimuth. This process is also called "reckoning."

In 1975, Vincenty published a rapidly converging algorithm for this calculation. Since then, his algorithm has since seen significant implementation in geodesy and engineering. The algorithm is precise to within a few millimeters. Please see code comments for references.

Michael Kleder, Nov 2007

Cite As

Michael Kleder (2021). VRECKON: Find the endpoint of a geodesic on the ellipsoidal earth (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)


After trying for 3 hours to generate an artificial gps-track (the task for the students would be figuring out the speed given a csv with coordinates and timestamps), I came across this. Thank you very much, exactly what I needed.

Bradley Wright

Correction: commenting line 100 yields results in -180 to 180 convention

Adam Hart

Awesome! Just what I needed! Thanks!

Kevin Ellis


I am having trouble producing the correct results using this submission. Over the past few days I have been trying to code my own program similar to this one and for a test point I kept getting the wrong answer. I eventually came across your code and it also gave the same answer my code gave for the test point. I have checked Google Earth and even the website that uses a Javascript to calculate the latitude and longitude of a point given a distance, bearing, and an initial point.

To illustrate my problem I have the following initial point latitude and longitude:

39° 44′ 42.41″N
105° 00′ 5.01″W



And the following distance (meters)

23.14288153 meters

And the following bearing

319°24′ 0″



Now when I send these values to the function you developed I get:

>> [x y] = vreckon(lat1, lon1, s, a12)

x =


y =


Now the value I get using the Javascript from the following website ( is:




As can be seen the latitude value matches well, but the longitude is far off. On that website the author even gives the code (using the same formulas you used) for the Javascript so I wasn't sure where the difference could be. Finally, I checked Google Earth and the latitude and longitude produced by the aforementioned website are the correct values. I believe the problem lies in using the "mod" function (my code uses it as well), but again I'm not sure.

Could you perhaps provide some insight into this problem? It would be of great help for my project where accuracy is a issue. Thanks.

Kevin Ellis

R Calabretta

Very useful tool for evaluating Required Navigation Performance (RNP) algorithms.

Thank you Michael. I appreciate the work you are doing in this area.

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!