Minimum distance between a point and a line in latitude, longitude

后端 未结 5 1962
感情败类
感情败类 2020-12-28 09:45

I have a line with two points in latitude and longitude
A: 3.222895, 101.719751
B: 3.227511, 101.724318

and 1 point
C: 3.224972, 101.722932

Ho

5条回答
  •  情歌与酒
    2020-12-28 10:29

    If you know how to calculate the distance of two points, get the distances between each two points, you get AB, AC, and BC. You want to know the closest distance between point C and line AB.

    First get the value of P

    P=(AB+BC+AC)/2
    

    Using P, you need to get S

    S=SQRT((P(P-AC)(P-AB)(P-AC)) 
    

    SQRT means square root. Then you get what you want by

    2*S/AB
    

提交回复
热议问题