Created
March 30, 2012 08:50
-
-
Save dadeba/2249962 to your computer and use it in GitHub Desktop.
Convert the Morton key to the Hilbert key in 3-D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A B C D E F G H I J K M | |
// 0 1 2 3 4 5 6 7 8 9 10 11 | |
struct HKeys { | |
static const uint64 T0[12][8]; | |
static const uint64 T1[12][8]; | |
uint64 poi(uint64 key, uint64 level) | |
{ | |
return (key >> 3*level)&0x7ULL; | |
} | |
uint64 Get(uint64 morton_key, uint64 maxlevel) | |
{ | |
uint64 key = 0; | |
uint64 l = 0; | |
for(uint64 level = maxlevel; level >= 1; level--) { | |
uint64 p = poi(morton_key, level); | |
uint64 oo = T0[l][p]; | |
key |= (oo << (level*3)); | |
l = T1[l][p]; | |
} | |
return key; | |
} | |
}; | |
const uint64 HKeys::T0[12][8] = { | |
{0, 2, 3, 1, 5, 7, 6, 4}, | |
{0, 1, 5, 4, 6, 7, 3, 2}, | |
{0, 4, 6, 2, 3, 7, 5, 1}, | |
{6, 4, 5, 7, 3, 1, 0, 2}, | |
{6, 7, 3, 2, 0, 1, 5, 4}, | |
{6, 2, 0, 4, 5, 1, 3, 7}, | |
{5, 7, 6, 4, 0, 2, 3, 1}, | |
{5, 4, 0, 1, 3, 2, 6, 7}, | |
{5, 1, 3, 7, 6, 2, 0, 4}, | |
{3, 1, 0, 2, 6, 4, 5, 7}, | |
{3, 2, 6, 7, 5, 4, 0, 1}, | |
{3, 7, 5, 1, 0, 4, 6, 2} | |
}; | |
const uint64 HKeys::T1[12][8] = { | |
{1, 2, 2, 9, 9, 8, 8, 4}, | |
{2, 0, 0, 7, 7, 3, 3, 11}, | |
{0, 1, 1, 5, 5, 10, 10, 6}, | |
{4, 5, 5, 6, 6, 11, 11, 1}, | |
{5, 3, 3, 10, 10, 0, 0, 8}, | |
{3, 4, 4, 2, 2, 7, 7, 9}, | |
{7, 8, 8, 3, 3, 2, 2, 10}, | |
{8, 6, 6, 1, 1, 9, 9, 5}, | |
{6, 7, 7, 11, 11, 4, 4, 0}, | |
{10, 11, 11, 0, 0, 5, 5, 7}, | |
{11, 9, 9, 4, 4, 6, 6, 2}, | |
{9, 10, 10, 8, 8, 1, 1, 3} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
板東, 西, & 鎌田, 「3次元擬似ヒルベルト走査法と動画像圧縮への応用」, 電子情報通信学会技術研究報告. MVE, マルチメディア・仮想環境基礎 98(208), 31-38, 1998-07-24, http://ci.nii.ac.jp/naid/110003270685
この論文のテーブルをソースコード化