Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c#: Distance from point to a line segment (in longitude and latitude)

I have a position (A) in longitude and latitude.

I have a line segment with start (B) and end (C) points in longitude and latitude.

What I am trying to calculate is the shortest distance from A to line B<->C. In other words the distance from A to the closest point (on line BC) in meters.

Thanks in advance.

like image 965
Robert Lancaster Avatar asked Oct 10 '22 22:10

Robert Lancaster


1 Answers

I think you could read this link to get the intersection point between A and the perpendicular line to BC passing on A.
Then using formulas (and code ready) from here you should be able to solve your problem.

like image 187
Marco Avatar answered Oct 13 '22 10:10

Marco