Click here to Skip to main content
15,611,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a straight line, GPS coordinate "A" and GPS coordinate "B".
Looking for the method or code example that would allow me to extend the A - B vector by "X" (meters, yards, feet, whatever) to give me "Z".
Non graphic image here (best I can do :-) ):


BTW - "Z" could be at either end of the known A - B points.
Example of coordinates I have: -116.63181685,32.71033345,0 -116.71756575,32.71401234,0


What I have tried:

Looked all over and everything I found basically gives me the distance between A - B.
Updated 23-Jan-21 19:01pm

extend straight line using GPS coordinates

GPS coordinates means that you want distances on earth which is basically spherical.
To compute distance between 2 points, you need to define the great circle between those points.
Great circle - Wikipedia[^]
Great-circle distance - Wikipedia[^]
Point Z will be on same great circle.
Share this answer
CPallini 24-Jan-21 5:59am    
Patrice T 24-Jan-21 6:27am    
thank you
Gary Paquette 25-Jan-21 12:09pm    
Understood and thanks. On a short distance like a mile the spherical is not a big concern, typically would need to be ablow 12 miles.
So from a math / code perspective. How would I extend the line?
Patrice T 25-Jan-21 13:02pm    
if you are near pole is a big concern even on small distance.
"How would I extend the line?"
I have not tried to solve this part.
Gary Paquette 25-Jan-21 22:58pm    
We only fly within the continental USA. Only if Santa Clause needs help - that might change :-)
Given you can work out the distance between A and B, you can then work out how to extend that vector by a certain distance. I've done the first bit, so this is basic maths to change it to do what you want
Share this answer
Gary Paquette 23-Jan-21 23:27pm    
Hi Christian - where can I find your "first bit"?
Example of the coordinates: -116.63181685,32.71033345,0 -116.71756575,32.71401234,0
Which is five miles. If I want to extend 1 mile, what is the method?
Christian Graus 24-Jan-21 0:26am    
The first bit is the algorithm you're using to find a distance between two lat/lng This is then just vector maths at that point. So if your two points are 2 miles and you want to add one mile, you need the vector point that's half as long again as the vector you have
CPallini 24-Jan-21 5:59am    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900