public void testContinuity() { Trace.WriteLine("TestContinuity"); // Make sure that sequentially increasing cell ids form a continuous // path over the surface of the sphere, i.e. there are no // discontinuous jumps from one region to another. var maxDist = S2Projections.MaxEdge.GetValue(MAX_WALK_LEVEL); var end = S2CellId.End(MAX_WALK_LEVEL); var id = S2CellId.Begin(MAX_WALK_LEVEL); for (; !id.Equals(end); id = id.Next) { Assert.True(id.ToPointRaw().Angle(id.NextWithWrap.ToPointRaw()) <= maxDist); // Check that the ToPointRaw() returns the center of each cell // in (s,t) coordinates. var p = id.ToPointRaw(); var face = S2Projections.XyzToFace(p); var uv = S2Projections.ValidFaceXyzToUv(face, p); assertDoubleNear(Math.IEEERemainder( S2Projections.UvToSt(uv.X), 1.0 / (1 << MAX_WALK_LEVEL)), 0); assertDoubleNear(Math.IEEERemainder( S2Projections.UvToSt(uv.Y), 1.0 / (1 << MAX_WALK_LEVEL)), 0); } }
public void testSTUV() { // Check boundary conditions. for (double x = -1; x <= 1; ++x) { assertEquals(S2Projections.StToUv(x), x); assertEquals(S2Projections.UvToSt(x), x); } // Check that UVtoST and STtoUV are inverses. for (double x = -1; x <= 1; x += 0.0001) { assertDoubleNear(S2Projections.UvToSt(S2Projections.StToUv(x)), x); assertDoubleNear(S2Projections.StToUv(S2Projections.UvToSt(x)), x); } }