public void Test_S2LatLng_NegativeZeros() { Assert.True(IsIdentical( S2LatLng.Latitude(new S2Point(1.0, 0.0, -0.0)).Radians, +0.0)); Assert.True(IsIdentical( S2LatLng.Longitude(new S2Point(1.0, -0.0, 0.0)).Radians, +0.0)); Assert.True(IsIdentical( S2LatLng.Longitude(new S2Point(-1.0, -0.0, 0.0)).Radians, S2.M_PI)); Assert.True(IsIdentical( S2LatLng.Longitude(new S2Point(-0.0, 0.0, 1.0)).Radians, +0.0)); Assert.True(IsIdentical( S2LatLng.Longitude(new S2Point(-0.0, -0.0, 1.0)).Radians, +0.0)); }
public void Test_RectBounder_MaxLatitudeRandom() { // Check that the maximum latitude of edges is computed accurately to within // 3 * S2Constants.DoubleEpsilon (the expected maximum error). We concentrate on maximum // latitudes near the equator and north pole since these are the extremes. const int kIters = 100; for (int iter = 0; iter < kIters; ++iter) { // Construct a right-handed coordinate frame (U,V,W) such that U points // slightly above the equator, V points at the equator, and W is slightly // offset from the north pole. S2Point u = S2Testing.RandomPoint(); u = new S2Point(u.X, u.Y, S2.DoubleEpsilon * 1e-6 * Math.Pow(1e12, S2Testing.Random.RandDouble())); // log is uniform u = u.Normalize(); S2Point v = S2.RobustCrossProd(new S2Point(0, 0, 1), u).Normalize(); S2Point w = S2.RobustCrossProd(u, v).Normalize(); // Construct a line segment AB that passes through U, and check that the // maximum latitude of this segment matches the latitude of U. S2Point a = (u - S2Testing.Random.RandDouble() * v).Normalize(); S2Point b = (u + S2Testing.Random.RandDouble() * v).Normalize(); S2LatLngRect ab_bound = GetEdgeBound(a, b); Assert2.Near(S2LatLng.Latitude(u).Radians, ab_bound.Lat.Hi, kRectError.LatRadians); // Construct a line segment CD that passes through W, and check that the // maximum latitude of this segment matches the latitude of W. S2Point c = (w - S2Testing.Random.RandDouble() * v).Normalize(); S2Point d = (w + S2Testing.Random.RandDouble() * v).Normalize(); S2LatLngRect cd_bound = GetEdgeBound(c, d); Assert2.Near(S2LatLng.Latitude(w).Radians, cd_bound.Lat.Hi, kRectError.LatRadians); } }