Calculate angle between two Latitude/Longitude points

后端 未结 17 1374
故里飘歌
故里飘歌 2020-12-07 17:51

Is there a way to calculate angle between two Latitude/Longitude points?

What I am trying to achieve is to know where the user is heading. For example, user is head

17条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-07 18:38

    Make sure its a rhumb line bearing NOT a great circle bearing as the initial bearing changes according to distance

     double angle= Math.min((pbearingf-tbearingf) < 0 ? pbearingf-tbearingf+360:pbearingf-tbearingf, (tbearingf-pbearingf)<0?tbearingf-pbearingf+360:tbearingf-pbearingf);
    

提交回复
热议问题