コード例 #1
0
ファイル: S2CellId.cs プロジェクト: pogosandbox/PoGoMITM
        /**
         * Convert (face, si, ti) coordinates (see s2.h) to a direction vector (not
         * necessarily unit length).
         */

        private static S2Point FaceSiTiToXyz(int face, int si, int ti)
        {
            const double kScale = 1.0 / MaxSize;
            var          u      = S2Projections.StToUv(kScale * si);
            var          v      = S2Projections.StToUv(kScale * ti);

            return(S2Projections.FaceUvToXyz(face, u, v));
        }
コード例 #2
0
ファイル: S2CellId.cs プロジェクト: pogosandbox/PoGoMITM
        /**
         * Given (i, j) coordinates that may be out of bounds, normalize them by
         * returning the corresponding neighbor cell on an adjacent face.
         */

        private static S2CellId FromFaceIjWrap(int face, int i, int j)
        {
            // Convert i and j to the coordinates of a leaf cell just beyond the
            // boundary of this face. This prevents 32-bit overflow in the case
            // of finding the neighbors of a face cell, and also means that we
            // don't need to worry about the distinction between (s,t) and (u,v).
            i = Math.Max(-1, Math.Min(MaxSize, i));
            j = Math.Max(-1, Math.Min(MaxSize, j));

            // Find the (s,t) coordinates corresponding to (i,j). At least one
            // of these coordinates will be just outside the range [0, 1].
            const double kScale = 1.0 / MaxSize;
            var          s      = kScale * ((i << 1) + 1 - MaxSize);
            var          t      = kScale * ((j << 1) + 1 - MaxSize);

            // Find the leaf cell coordinates on the adjacent face, and convert
            // them to a cell id at the appropriate level.
            var p = S2Projections.FaceUvToXyz(face, s, t);

            face = S2Projections.XyzToFace(p);
            var st = S2Projections.ValidFaceXyzToUv(face, p);

            return(FromFaceIj(face, StToIj(st.X), StToIj(st.Y)));
        }
コード例 #3
0
        // Internal method that does the actual work in the constructors.

        private double GetLatitude(int i, int j)
        {
            var p = S2Projections.FaceUvToXyz(_face, _uv[0][i], _uv[1][j]);

            return(Math.Atan2(p.Z, Math.Sqrt(p.X * p.X + p.Y * p.Y)));
        }
コード例 #4
0
        private double GetLongitude(int i, int j)
        {
            var p = S2Projections.FaceUvToXyz(_face, _uv[0][i], _uv[1][j]);

            return(Math.Atan2(p.Y, p.X));
        }
コード例 #5
0
        /**
         * Return the k-th vertex of the cell (k = 0,1,2,3). Vertices are returned in
         * CCW order. The points returned by GetVertexRaw are not necessarily unit
         * length.
         */

        public S2Point GetVertexRaw(int k)
        {
            // Vertices are returned in the order SW, SE, NE, NW.
            return(S2Projections.FaceUvToXyz(_face, _uv[0][(k >> 1) ^ (k & 1)], _uv[1][k >> 1]));
        }