how to use direction angle and speed to calculate next time's latitude and longitude

前端 未结 5 1651
自闭症患者
自闭症患者 2021-02-04 07:42

I have know my current position({lat:x,lon:y}) and I know my speed and direction angle; How to predict next position at next time?

5条回答
  •  忘掉有多难
    2021-02-04 08:18

    Same code in Java:

        final double r = 6371 * 1000; // Earth Radius in m
    
        double lat2 = Math.asin(Math.sin(Math.toRadians(lat)) * Math.cos(distance / r)
                + Math.cos(Math.toRadians(lat)) * Math.sin(distance / r) * Math.cos(Math.toRadians(bearing)));
        double lon2 = Math.toRadians(lon)
                + Math.atan2(Math.sin(Math.toRadians(bearing)) * Math.sin(distance / r) * Math.cos(Math.toRadians(lat)), Math.cos(distance / r)
                - Math.sin(Math.toRadians(lat)) * Math.sin(lat2));
        lat2 = Math.toDegrees( lat2);
        lon2 = Math.toDegrees(lon2);
    

提交回复
热议问题