@@ -44,9 +44,16 @@ TEST(SphericalUtil, interpolate) {
4444
4545 // two nearby points, separated by ~4m, for which the Slerp algorithm is not stable and we
4646 // have to fall back to linear interpolation.
47- LatLng interpolateResult = SphericalUtil::interpolate (LatLng (-37.756891 , 175.325262 ), LatLng (-37.756853 , 175.325242 ), 0.5 );
47+ LatLng nearA (-37.756891 , 175.325262 );
48+ LatLng nearB (-37.756853 , 175.325242 );
49+
50+ LatLng interpolateResult = SphericalUtil::interpolate (nearA, nearB, 0.5 );
4851 LatLng goldenResult (-37.756872 , 175.325252 );
52+ EXPECT_NEAR (interpolateResult.lat , goldenResult.lat , 1e-6 );
53+ EXPECT_NEAR (interpolateResult.lng , goldenResult.lng , 1e-6 );
4954
50- EXPECT_NEAR (interpolateResult.lat , goldenResult.lat , 2e-5 );
51- EXPECT_NEAR (interpolateResult.lng , goldenResult.lng , 2e-5 );
55+ // fraction=1.0 must return 'to', not 'from'
56+ LatLng endResult = SphericalUtil::interpolate (nearA, nearB, 1.0 );
57+ EXPECT_NEAR (endResult.lat , nearB.lat , 1e-6 );
58+ EXPECT_NEAR (endResult.lng , nearB.lng , 1e-6 );
5259}
0 commit comments