Пример #1
0
        // Get vertex coordinates for the patch type 'T'
        // [C, NW, NE, SW, SE] = HealpixGetPatchVertexCoordsT(n, i, j, INFO)
        //
        // Parameters
        // n : grid resolution
        // i : ring index
        // j : intra-ring index
        // INFO : intermediate information (output of HealpixSelectPatchClass())
        // C : intra-patch coordinates
        // NW : coordinates for north-east vertex
        // NE : coordinates for north-west vertex
        // SW, SE : coordinates for south vertex (always SW = SE since the patch is triangular shape)
        void HealpixGetPatchVertexCoordsT(int n, double i, double j, HealpixPointInfo INFO,
                                          out HealpixIndex C, out HealpixIndexInt NW, out HealpixIndexInt NE, out HealpixIndexInt SW, out HealpixIndexInt SE)
        {
            C  = new HealpixIndex();
            NW = new HealpixIndexInt();
            NE = new HealpixIndexInt();
            SW = new HealpixIndexInt();
            SE = new HealpixIndexInt();

            int int_j = (int)j;

            if (int_j == 0)
            {
                int_j = 4 * n;
            }
            int east_int_j = ((int_j + 1 - 1) % (4 * INFO.int_i_n)) + 1;

            double decimal_i;

            if (INFO.is_south_pole == false)
            {
                NW.i = n;
                NW.j = int_j;
                NE.i = n;
                NE.j = east_int_j;
                SW.i = n + 1;
                SW.j = int_j;
                SE.i = SW.i;
                SE.j = SW.j;

                decimal_i = INFO.decimal_i_n;
            }
            else
            {
                SW.i = 3 * n;
                SW.j = int_j;
                SE.i = 3 * n;
                SE.j = east_int_j;
                NW.i = 3 * n - 1;
                NW.j = int_j;
                NE.i = NW.i;
                NE.j = NW.j;

                decimal_i = 1.0 - INFO.decimal_i_n;
            }

            double decimal_j = INFO.decimal_polar_intra_part;

            if (1 > INFO.decimal_i_n)
            {
                C.i = decimal_i - 0.5;
                C.j = decimal_j / (1.0 - INFO.decimal_i_n) - 0.5;
            }
            else
            {
                C.i = decimal_i - 0.5;
                C.j = decimal_j - 0.5;
            }
        }
Пример #2
0
        // Get vertex coordinates for the patch type 'R'
        // [C, NW, NE, SW, SE] = HealpixGetPatchVertexCoordsR(n, i, j, INFO)
        //
        // Parameters
        // n : grid resolution
        // i : ring index
        // j : intra-ring index
        // INFO : intermediate information (output of HealpixSelectPatchClass())
        // C : intra-patch coordinates
        // NW : coordinates for north-east vertex
        // NE : coordinates for north-west vertex
        // SW : coordinates for south-west vertex
        // SE : coordinates for south-east vertex
        void HealpixGetPatchVertexCoordsR(int n, double i, double j, HealpixPointInfo INFO,
                                          out HealpixIndex C, out HealpixIndexInt NW, out HealpixIndexInt NE, out HealpixIndexInt SW, out HealpixIndexInt SE)
        {
            C  = new HealpixIndex();
            NW = new HealpixIndexInt();
            NE = new HealpixIndexInt();
            SW = new HealpixIndexInt();
            SE = new HealpixIndexInt();

            // gradient of the border
            int grad = INFO.polar_part;

            int delta_int_i_n = INFO.int_i_n - 1;
            int north_west_j  = grad + grad * delta_int_i_n;
            int south_west_j  = north_west_j + grad;

            int north_i_n = INFO.int_i_n;
            int south_i_n = INFO.int_i_n + 1;

            north_west_j = ((north_west_j - 1) % (4 * north_i_n)) + 1;
            int north_east_j = ((north_west_j + 1 - 1) % (4 * north_i_n)) + 1;

            south_west_j = ((south_west_j - 1) % (4 * south_i_n)) + 1;
            int south_east_j = ((south_west_j + 1 - 1) % (4 * south_i_n)) + 1;

            if (INFO.is_south_pole == false)
            {
                NW.i = north_i_n;
                NW.j = north_west_j;
                NE.i = north_i_n;
                NE.j = north_east_j;
                SW.i = south_i_n;
                SW.j = south_west_j;
                SE.i = south_i_n;
                SE.j = south_east_j;
                C.i  = INFO.decimal_i_n - 0.5;
                C.j  = INFO.polar_intra_part - 0.5;
            }
            else
            {
                north_i_n = 4 * n - north_i_n;
                south_i_n = 4 * n - south_i_n;
                NW.i      = south_i_n;
                NW.j      = south_west_j;
                NE.i      = south_i_n;
                NE.j      = south_east_j;
                SW.i      = north_i_n;
                SW.j      = north_west_j;
                SE.i      = north_i_n;
                SE.j      = north_east_j;
                C.i       = 1.0 - INFO.decimal_i_n - 0.5;
                C.j       = INFO.polar_intra_part - 0.5;
            }
        }
Пример #3
0
        // Get adjacent pixels coordinates for integer position
        void HealpixGetAdjacentCoords(int n, HealpixIndexInt POS, HealpixDirection dir,
                                      out HealpixIndexInt P0, out HealpixIndexInt P1)
        {
            // ここで、上下左右に座標を少しづつ動かしてHealpixGetAdjacentVertexを呼んで、
            // 4方向のペアを求める
            P0 = new HealpixIndexInt();
            P1 = new HealpixIndexInt();

            switch (dir)
            {
            case HealpixDirection.DIR_VERTICAL:
                break;

            case HealpixDirection.DIR_HORIZONTAL:
                break;

            case HealpixDirection.DIR_OBLIQUE_P:
                break;

            case HealpixDirection.DIR_OBLIQUE_N:
                break;
            }
        }
Пример #4
0
        // Get adjacent pixels coordinates for NOT integer position
        void HealpixGetAdjacentVertex(int n, HealpixIndex POS,
                                      out HealpixIndexInt P0, out HealpixIndexInt P1, out HealpixIndexInt P2, out HealpixIndexInt P3)
        {
            HealpixPointInfo info = HealpixSelectPatchClass(n, POS.i, POS.j);
            HealpixIndex     C;

            switch (info.patch_class)
            {
            case HealpixPatchClass.PATCH_CLASS_O:
                HealpixGetPatchVertexCoordsO(n, POS.i, POS.j, info, out C, out P0, out P1, out P2, out P3);
                break;

            case HealpixPatchClass.PATCH_CLASS_R:
                HealpixGetPatchVertexCoordsR(n, POS.i, POS.j, info, out C, out P0, out P1, out P2, out P3);
                break;

            case HealpixPatchClass.PATCH_CLASS_T:
                HealpixGetPatchVertexCoordsT(n, POS.i, POS.j, info, out C, out P0, out P1, out P2, out P3);
                break;

            case HealpixPatchClass.PATCH_CLASS_P:
                HealpixGetPatchVertexCoordsP(n, POS.i, POS.j, info, out C, out P0, out P1, out P2, out P3);
                break;

            case HealpixPatchClass.PATCH_CLASS_E:
                HealpixGetPatchVertexCoordsE(n, POS.i, POS.j, info, out C, out P0, out P1, out P2, out P3);
                break;

            case HealpixPatchClass.PATCH_CLASS_B:
                HealpixGetPatchVertexCoordsB(n, POS.i, POS.j, info, out C, out P0, out P1, out P2, out P3);
                break;

            case HealpixPatchClass.PATCH_CLASS_V:
            default:
                throw new System.NotImplementedException();
            }
        }
Пример #5
0
        // Get vertex coordinates for the patch type 'P'
        // [C, N, S, W, E] = HealpixGetPatchVertexCoordsP(n, i, j, INFO)
        //
        // Parameters
        // n : grid resolution
        // i : ring index
        // j : intra-ring index
        // INFO : intermediate information (output of HealpixSelectPatchClass())
        // C : intra-patch coordinates
        // N : coordinates for north vertex
        // S : coordinates for south vertex
        // W : coordinates for west vertex
        // E : coordinates for east vertex
        void HealpixGetPatchVertexCoordsP(int n, double i, double j, HealpixPointInfo INFO,
                                          out HealpixIndex C, out HealpixIndexInt N, out HealpixIndexInt S, out HealpixIndexInt W, out HealpixIndexInt E)
        {
            C = new HealpixIndex();
            N = new HealpixIndexInt();
            S = new HealpixIndexInt();
            W = new HealpixIndexInt();
            E = new HealpixIndexInt();

            // gradient of the border
            int grad = INFO.polar_part;

            double decimal_i = INFO.decimal_i_n;
            int    int_i     = INFO.int_i_n;

            int    int_j     = (int)(j - grad * decimal_i);
            double decimal_j = j - int_j;

            if (int_j == 0)
            {
                int_j = 4 * int_i;
            }

            if (decimal_j > (grad + 1) * decimal_i)
            {
                int north_i     = int_i - 1;
                int south_i     = int_i + 1;
                int north_int_j = ((int_j - grad - 1) % (4 * north_i)) + 1;
                int south_int_j = ((int_j + (grad + 1) - 1) % (4 * south_i)) + 1;
                int east_int_j  = ((int_j + 1 - 1) % (4 * int_i)) + 1;

                N.i = north_i;
                N.j = north_int_j;
                S.i = south_i;
                S.j = south_int_j;
                W.i = int_i;
                W.j = int_j;
                E.i = int_i;
                E.j = east_int_j;

                double offset_j = (grad + 0.5) * decimal_i;
                C.i = decimal_i;
                C.j = decimal_j - offset_j - 0.5;
            }
            else
            {
                int curnt_i = int_i + 1;
                int south_i = int_i + 2;
                if (south_i > n)
                {
                    south_i = n;
                }
                int west_int_j  = ((int_j + grad - 1) % (4 * curnt_i)) + 1;
                int east_int_j  = ((int_j + grad + 1 - 1) % (4 * curnt_i)) + 1;
                int south_int_j = ((west_int_j + (grad + 1) - 1) % (4 * south_i)) + 1;

                N.i = int_i;
                N.j = int_j;
                S.i = int_i + 2;
                S.j = south_int_j;
                W.i = int_i + 1;
                W.j = west_int_j;
                E.i = int_i + 1;
                E.j = east_int_j;

                double offset_j = (grad + 0.5) * (1.0 - decimal_i);
                C.i = decimal_i - 1;
                C.j = decimal_j + offset_j - (grad + 0.5);
            }

            if (INFO.is_south_pole)
            {
                HealpixIndexInt TMP = N;
                N   = S;
                S   = TMP;
                N.i = 4 * n - N.i;
                S.i = 4 * n - S.i;
                W.i = 4 * n - W.i;
                E.i = 4 * n - E.i;
                C.i = -C.i;
            }
        }
Пример #6
0
        // Get vertex coordinates for the patch type 'O'
        // [C, N, S, W, E] = HealpixGetPatchVertexCoordsO(n, i, j, INFO)
        //
        // Parameters
        // n : grid resolution
        // i : ring index
        // j : intra-ring index
        // INFO : intermediate information (output of HealpixSelectPatchClass())
        // C : intra-patch coordinates
        // P0 : (i, j) = (1, 1)
        // P1 : (i, j) = (1, 2)
        // P2 : (i, j) = (1, 3)
        // P3 : (i, j) = (1, 4)
        void HealpixGetPatchVertexCoordsO(int n, double i, double j, HealpixPointInfo INFO,
                                          out HealpixIndex C, out HealpixIndexInt P0, out HealpixIndexInt P1, out HealpixIndexInt P2, out HealpixIndexInt P3)
        {
            C  = new HealpixIndex();
            P0 = new HealpixIndexInt();
            P1 = new HealpixIndexInt();
            P2 = new HealpixIndexInt();
            P3 = new HealpixIndexInt();

            if (INFO.is_south_pole == false)
            {
                P0.i = 1;
                P0.j = 1;
                P1.i = 1;
                P1.j = 2;
                P2.i = 1;
                P2.j = 4;
                P3.i = 1;
                P3.j = 3;
            }
            else
            {
                P0.i = 4 * n - 1;
                P0.j = 1;
                P1.i = 4 * n - 1;
                P1.j = 2;
                P2.i = 4 * n - 1;
                P2.j = 4;
                P3.i = 4 * n - 1;
                P3.j = 3;
            }

            int    int_j     = (int)j;
            double decimal_j = j - int_j;

            if (int_j == 0)
            {
                int_j = 4;
            }

            double decimal_i_n     = INFO.i_n;
            double delta_decimal_i = decimal_i_n / 2;
            double delta_decimal_j = decimal_j * decimal_i_n;
            double offset_j        = 0.5 - delta_decimal_i;

            switch (int_j)
            {
            case 1:
                C.i = 0.5 - delta_decimal_i;
                C.j = offset_j + delta_decimal_j;
                break;

            case 2:
                C.i = offset_j + delta_decimal_j;
                C.j = 0.5 + delta_decimal_i;
                break;

            case 3:
                C.i = 0.5 + delta_decimal_i;
                C.j = 1.0 - (offset_j + delta_decimal_j);
                break;

            case 4:
                C.i = 1.0 - (offset_j + delta_decimal_j);
                C.j = 0.5 - delta_decimal_i;
                break;
            }

            C.i -= 0.5;
            C.j -= 0.5;
        }
Пример #7
0
        // Get vertex coordinates for the patch type 'E'
        // [C, N, S, W, E] = HealpixGetPatchVertexCoordsE(n, i, j)
        //
        // Parameters
        // n : grid resolution
        // i : ring index
        // j : intra-ring index
        // C : intra-patch coordinates
        // N : coordinates for north vertex
        // S : coordinates for south vertex
        // W : coordinates for west vertex
        // E : coordinates for east vertex
        void HealpixGetPatchVertexCoordsE(int n, double i, double j, HealpixPointInfo INFO,
                                          out HealpixIndex C, out HealpixIndexInt N, out HealpixIndexInt S, out HealpixIndexInt W, out HealpixIndexInt E)
        {
            C = new HealpixIndex();
            N = new HealpixIndexInt();
            S = new HealpixIndexInt();
            W = new HealpixIndexInt();
            E = new HealpixIndexInt();

            int    int_i     = (int)i;
            int    int_j     = (int)j;
            double decimal_i = i - int_i;
            double decimal_j = j - int_j;

            if (int_j == 0)
            {
                int_j = 4 * n;
            }

            int east_int_j = ((int_j + 1 - 1) % (4 * n)) + 1;

            if ((int_i - n) % 2 == 0)
            {
                if (decimal_i < 1.0 - decimal_j)
                {
                    N.i = int_i - 1;
                    N.j = int_j;
                    S.i = int_i + 1;
                    S.j = int_j;
                    W.i = int_i;
                    W.j = int_j;
                    E.i = int_i;
                    E.j = east_int_j;

                    double offset_j = 0.5 * decimal_i;
                    C.i = decimal_i;
                    C.j = decimal_j + offset_j - 0.5;
                }
                else
                {
                    N.i = int_i;
                    N.j = east_int_j;
                    S.i = int_i + 2;
                    S.j = east_int_j;
                    W.i = int_i + 1;
                    W.j = int_j;
                    E.i = int_i + 1;
                    E.j = east_int_j;

                    double offset_j = 0.5 * (1.0 - decimal_i);
                    C.i = decimal_i - 1;
                    C.j = decimal_j - offset_j - 0.5;
                }
            }
            else
            {
                if (decimal_i < decimal_j)
                {
                    N.i = int_i - 1;
                    N.j = east_int_j;
                    S.i = int_i + 1;
                    S.j = east_int_j;
                    W.i = int_i;
                    W.j = int_j;
                    E.i = int_i;
                    E.j = east_int_j;

                    double offset_j = 0.5 * decimal_i;
                    C.i = decimal_i;
                    C.j = decimal_j - offset_j - 0.5;
                }
                else
                {
                    N.i = int_i;
                    N.j = int_j;
                    S.i = int_i + 2;
                    S.j = int_j;
                    W.i = int_i + 1;
                    W.j = int_j;
                    E.i = int_i + 1;
                    E.j = east_int_j;

                    double offset_j = 0.5 * (1.0 - decimal_i);
                    C.i = decimal_i - 1;
                    C.j = decimal_j + offset_j - 0.5;
                }
            }
        }
Пример #8
0
        // Get vertex coordinates for the patch type 'B'
        // [C, N, S, W, E] = HealpixGetPatchVertexCoordsB(n, i, j, INFO)
        //
        // Parameters
        // n : grid resolution
        // i : ring index
        // j : intra-ring index
        // INFO : intermediate information (output of HealpixSelectPatchClass())
        // C : intra-patch coordinates
        // N : coordinates for north vertex
        // S : coordinates for south vertex
        // W : coordinates for west vertex
        // E : coordinates for east vertex
        void HealpixGetPatchVertexCoordsB(int n, double i, double j, HealpixPointInfo INFO,
                                          out HealpixIndex C, out HealpixIndexInt N, out HealpixIndexInt S, out HealpixIndexInt W, out HealpixIndexInt E)
        {
            C = new HealpixIndex();
            N = new HealpixIndexInt();
            S = new HealpixIndexInt();
            W = new HealpixIndexInt();
            E = new HealpixIndexInt();

            // gradient of the border
            int grad = INFO.polar_part;

            double decimal_i = INFO.decimal_i_n;
            double decimal_j = INFO.decimal_polar_intra_part;

            int int_i = INFO.int_i_n;
            int int_j;

            if (int_i == n)
            {
                int_j = (int)j;
                if (int_j == 0)
                {
                    int_j = 4 * INFO.int_i_n;
                }

                int north_int_j = ((int_j - grad - 1) % (4 * (n - 1))) + 1;
                int east_int_j  = ((int_j + 1 - 1) % (4 * n)) + 1;

                N.i = int_i - 1;
                N.j = north_int_j;
                S.i = int_i + 1;
                S.j = int_j;
                W.i = int_i;
                W.j = int_j;
                E.i = int_i;
                E.j = east_int_j;

                double offset_j = 0.5 * decimal_i;
                C.i = decimal_i;
                C.j = decimal_j + offset_j - 0.5;
            }
            else
            {
                int_j = (int)(j - grad * decimal_i);
                if (int_j == 0)
                {
                    int_j = 4 * n;
                }

                int west_int_j = ((int_j + grad - 1) % (4 * n)) + 1;
                int east_int_j = ((west_int_j + 1 - 1) % (4 * n)) + 1;

                N.i = int_i;
                N.j = int_j;
                S.i = int_i + 2;
                S.j = west_int_j;
                W.i = int_i + 1;
                W.j = west_int_j;
                E.i = int_i + 1;
                E.j = east_int_j;

                double offset_j = 0.5 * (1 - decimal_i);
                C.i = decimal_i - 1;
                C.j = decimal_j + offset_j - 0.5;
            }

            if (INFO.is_south_pole)
            {
                HealpixIndexInt TMP = N;
                N   = S;
                S   = TMP;
                N.i = 4 * n - N.i;
                S.i = 4 * n - S.i;
                W.i = 4 * n - W.i;
                E.i = 4 * n - E.i;
                C.i = -C.i;
            }
        }