Angle between 2 GPS Coordinates

后端 未结 2 2037
别那么骄傲
别那么骄傲 2020-12-28 22:54

I\'m working in another iPhone App that uses AR, and I\'m creating my own framework, but I\'m having trouble trying to get the angle of a second coordinate relative to the c

2条回答
  •  时光取名叫无心
    2020-12-28 23:09

    Here is the android version of this code

    import com.google.android.maps.GeoPoint;
        public double calculateAngle(GeoPoint startPoint, GeoPoint endPoint) {
            double lat1 = startPoint.getLatitudeE6() / 1E6;
            double lat2 = endPoint.getLatitudeE6() / 1E6;
            double long2 = startPoint.getLongitudeE6() / 1E6;
            double long1 = endPoint.getLongitudeE6() / 1E6;
            double dy = lat2 - lat1;
            double dx = Math.cos(Math.PI / 180 * lat1) * (long2 - long1);
            double angle = Math.atan2(dy, dx);
            return angle;
        }
    

提交回复
热议问题