Beispiel #1
0
        public void Test_FaceUVtoXYZ()
        {
            // Check that each face appears exactly once.
            S2Point sum = S2Point.Empty;

            for (int face = 0; face < 6; ++face)
            {
                S2Point center = S2.FaceUVtoXYZ(face, 0, 0);
                Assert.Equal(S2.GetNorm(face), center);
                Assert.Equal(1, Math.Abs(center[center.LargestAbsComponent()]));
                sum += center.Fabs();
            }
            Assert.Equal(sum, new S2Point(2, 2, 2));

            // Check that each face has a right-handed coordinate system.
            for (int face = 0; face < 6; ++face)
            {
                Assert.Equal(1, S2.GetUAxis(face).CrossProd(S2.GetVAxis(face))
                             .DotProd(S2.FaceUVtoXYZ(face, 0, 0)));
            }

            // Check that the Hilbert curves on each face combine to form a
            // continuous curve over the entire cube.
            for (int face = 0; face < 6; ++face)
            {
                // The Hilbert curve on each face starts at (-1,-1) and terminates
                // at either (1,-1) (if axes not swapped) or (-1,1) (if swapped).
                int sign = ((face & S2.kSwapMask) != 0) ? -1 : 1;
                Assert.Equal(S2.FaceUVtoXYZ(face, sign, -sign),
                             S2.FaceUVtoXYZ((face + 1) % 6, -1, -1));
            }
        }