@@ -29,16 +29,16 @@ class SphericalUtil {
2929 */
3030 inline static double computeHeading (const LatLng& from, const LatLng& to) {
3131 // http://williams.best.vwh.net/avform.htm#Crs
32- double fromLat = deg2rad (from.lat );
33- double fromLng = deg2rad (from.lng );
34- double toLat = deg2rad (to.lat );
35- double toLng = deg2rad (to.lng );
32+ double fromLat = MathUtil:: deg2rad (from.lat );
33+ double fromLng = MathUtil:: deg2rad (from.lng );
34+ double toLat = MathUtil:: deg2rad (to.lat );
35+ double toLng = MathUtil:: deg2rad (to.lng );
3636 double dLng = toLng - fromLng;
3737 double heading = atan2 (
3838 sin (dLng) * cos (toLat),
3939 cos (fromLat) * sin (toLat) - sin (fromLat) * cos (toLat) * cos (dLng));
4040
41- return MathUtil::wrap (rad2deg (heading), -180 , 180 );
41+ return MathUtil::wrap (MathUtil:: rad2deg (heading), -180 , 180 );
4242 }
4343
4444
@@ -52,10 +52,10 @@ class SphericalUtil {
5252 */
5353 inline static LatLng computeOffset (const LatLng& from, double distance, double heading) {
5454 distance /= MathUtil::EARTH_RADIUS;
55- heading = deg2rad (heading);
55+ heading = MathUtil:: deg2rad (heading);
5656 // http://williams.best.vwh.net/avform.htm#LL
57- double fromLat = deg2rad (from.lat );
58- double fromLng = deg2rad (from.lng );
57+ double fromLat = MathUtil:: deg2rad (from.lat );
58+ double fromLng = MathUtil:: deg2rad (from.lng );
5959 double cosDistance = cos (distance);
6060 double sinDistance = sin (distance);
6161 double sinFromLat = sin (fromLat);
@@ -65,7 +65,7 @@ class SphericalUtil {
6565 sinDistance * cosFromLat * sin (heading),
6666 cosDistance - sinFromLat * sinLat);
6767
68- return LatLng (rad2deg (asin (MathUtil::clamp (sinLat, -1.0 , 1.0 ))), rad2deg (fromLng + dLng));
68+ return LatLng (MathUtil:: rad2deg (asin (MathUtil::clamp (sinLat, -1.0 , 1.0 ))), MathUtil:: rad2deg (fromLng + dLng));
6969 }
7070
7171
@@ -81,13 +81,13 @@ class SphericalUtil {
8181 * @param heading The heading in degrees clockwise from north.
8282 */
8383 inline static std::optional<LatLng> computeOffsetOrigin (const LatLng& to, double distance, double heading) {
84- heading = deg2rad (heading);
84+ heading = MathUtil:: deg2rad (heading);
8585 distance /= MathUtil::EARTH_RADIUS;
8686 // http://lists.maptools.org/pipermail/proj/2008-October/003939.html
8787 double n1 = cos (distance);
8888 double n2 = sin (distance) * cos (heading);
8989 double n3 = sin (distance) * sin (heading);
90- double n4 = sin (deg2rad (to.lat ));
90+ double n4 = sin (MathUtil:: deg2rad (to.lat ));
9191 // Rewrite n4 = n1*sin(φ) + n2*cos(φ) as r*sin(φ + α) = n4,
9292 // where r = sqrt(n1²+n2²), α = atan2(n2, n1).
9393 // Solving via asin avoids dividing by n1, which causes catastrophic
@@ -103,8 +103,8 @@ class SphericalUtil {
103103 fromLatRadians = M_PI - asin (sinArg) - alpha;
104104 }
105105 if (fromLatRadians < -M_PI / 2 || fromLatRadians > M_PI / 2 ) return std::nullopt ;
106- double fromLngRadians = deg2rad (to.lng ) - atan2 (n3, n1 * cos (fromLatRadians) - n2 * sin (fromLatRadians));
107- return LatLng (rad2deg (fromLatRadians), rad2deg (fromLngRadians));
106+ double fromLngRadians = MathUtil:: deg2rad (to.lng ) - atan2 (n3, n1 * cos (fromLatRadians) - n2 * sin (fromLatRadians));
107+ return LatLng (MathUtil:: rad2deg (fromLatRadians), MathUtil:: rad2deg (fromLngRadians));
108108 }
109109
110110
@@ -120,10 +120,10 @@ class SphericalUtil {
120120 */
121121 inline static LatLng interpolate (const LatLng& from, const LatLng& to, double fraction) {
122122 // http://en.wikipedia.org/wiki/Slerp
123- double fromLat = deg2rad (from.lat );
124- double fromLng = deg2rad (from.lng );
125- double toLat = deg2rad (to.lat );
126- double toLng = deg2rad (to.lng );
123+ double fromLat = MathUtil:: deg2rad (from.lat );
124+ double fromLng = MathUtil:: deg2rad (from.lng );
125+ double toLat = MathUtil:: deg2rad (to.lat );
126+ double toLng = MathUtil:: deg2rad (to.lng );
127127 double cosFromLat = cos (fromLat);
128128 double cosToLat = cos (toLat);
129129 // Computes Spherical interpolation coefficients.
@@ -143,15 +143,15 @@ class SphericalUtil {
143143 // Converts interpolated vector back to polar.
144144 double lat = atan2 (z, sqrt (x * x + y * y));
145145 double lng = atan2 (y, x);
146- return LatLng (rad2deg (lat), rad2deg (lng));
146+ return LatLng (MathUtil:: rad2deg (lat), MathUtil:: rad2deg (lng));
147147 }
148148
149149 /* *
150150 * Returns the angle between two LatLngs, in radians. This is the same as the distance
151151 * on the unit sphere.
152152 */
153153 inline static double computeAngleBetween (const LatLng& from, const LatLng& to) {
154- return SphericalUtil::distanceRadians (deg2rad (from.lat ), deg2rad (from.lng ), deg2rad (to.lat ), deg2rad (to.lng ));
154+ return SphericalUtil::distanceRadians (MathUtil:: deg2rad (from.lat ), MathUtil:: deg2rad (from.lng ), MathUtil:: deg2rad (to.lat ), MathUtil:: deg2rad (to.lng ));
155155 }
156156
157157 /* *
@@ -171,11 +171,11 @@ class SphericalUtil {
171171 }
172172 double length = 0 ;
173173 LatLng prev = path[0 ];
174- double prevLat = deg2rad (prev.lat );
175- double prevLng = deg2rad (prev.lng );
174+ double prevLat = MathUtil:: deg2rad (prev.lat );
175+ double prevLng = MathUtil:: deg2rad (prev.lng );
176176 for (auto point : path) {
177- double lat = deg2rad (point.lat );
178- double lng = deg2rad (point.lng );
177+ double lat = MathUtil:: deg2rad (point.lat );
178+ double lng = MathUtil:: deg2rad (point.lng );
179179 length += SphericalUtil::distanceRadians (prevLat, prevLng, lat, lng);
180180 prevLat = lat;
181181 prevLng = lng;
@@ -227,13 +227,13 @@ class SphericalUtil {
227227 if (size < 3U ) { return 0 ; }
228228 double total = 0 ;
229229 LatLng prev = path[size - 1 ];
230- double prevTanLat = tan ((M_PI / 2 - deg2rad (prev.lat )) / 2 );
231- double prevLng = deg2rad (prev.lng );
230+ double prevTanLat = tan ((M_PI / 2 - MathUtil:: deg2rad (prev.lat )) / 2 );
231+ double prevLng = MathUtil:: deg2rad (prev.lng );
232232 // For each edge, accumulate the signed area of the triangle formed by the North Pole
233233 // and that edge ("polar triangle").
234234 for (auto point : path) {
235- double tanLat = tan ((M_PI / 2 - deg2rad (point.lat )) / 2 );
236- double lng = deg2rad (point.lng );
235+ double tanLat = tan ((M_PI / 2 - MathUtil:: deg2rad (point.lat )) / 2 );
236+ double lng = MathUtil:: deg2rad (point.lng );
237237 total += SphericalUtil::polarTriangleArea (tanLat, lng, prevTanLat, prevLng);
238238 prevTanLat = tanLat;
239239 prevLng = lng;
0 commit comments