Mercurial > hg > soniczoomios
diff hilbert.cpp @ 35:790939017078
V0.5. Now uses new continuous hilbert curve. HOORAY.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Mon, 08 Apr 2013 17:23:13 +0100 |
parents | 94df2cd72d7b |
children | a42903c61558 |
line wrap: on
line diff
--- a/hilbert.cpp Mon Apr 08 12:58:21 2013 +0100 +++ b/hilbert.cpp Mon Apr 08 17:23:13 2013 +0100 @@ -58,10 +58,11 @@ bin[i] = (number/(1 << pwr)) % 2; bin.push_back(0); } - + return bin; } +//-------------------------------------------------------------------- void printBool(vector <bool> vcode){ vector<bool>::iterator bit; @@ -83,7 +84,7 @@ // whole process unit test(?) - unsigned long long inCoord = 888999777; + unsigned long long inCoord = 982635920; vector<int> checkParam; checkParam = calculateParamsFromIndex(inCoord); cout << "PARAMS: "; @@ -92,7 +93,7 @@ } cout << '\n'; unsigned long long outCoord = calculateIndexFromParams(checkParam); - cout << "Unit TEst coord = " << outCoord << "\n"; + cout << "UNIT TEST COORD = " << outCoord << "\n"; } @@ -196,11 +197,11 @@ subindex = index >> blev*P; subindex = mask & subindex; - cout << "subindex: " << subindex << "\n"; + //cout << "subindex: " << subindex << "\n"; // which vertex corresponds to this index? if(subindex < theGrayCode.size()) vertex = theGrayCodeD[subindex]; - cout << "rotated: " << vertex << "\n"; + //cout << "rotated: " << vertex << "\n"; //% inverse rotate this T_e,d @@ -208,7 +209,7 @@ directionInv = (P - direction - 2); vertex = rotate(vertex,entryPointInv,directionInv); - cout << "vertex: " << vertex << "\n"; + //cout << "vertex: " << vertex << "\n"; //% build up bits of params @@ -224,7 +225,7 @@ int lse2 = rotr(newe, P-direction-1,P); entryPoint = entryPoint ^ lse2; direction = (direction + newd + 1) % P; - cout << "------------\n"; + //cout << "------------\n"; } return params; @@ -239,16 +240,16 @@ //-------------------------------------------------------------------- -long long Hilbert::calculateIndexFromParams(vector<int> params){ +unsigned long long Hilbert::calculateIndexFromParams(vector<int> params){ // set %set start and direction of biggest cube - long long h = 0; + unsigned long long h = 0; unsigned int i; unsigned int entryPoint = 0; int direction = P - 1; - unsigned int vertex=0, subindex=0, newe=0, newd=0; - + unsigned int vertex=0, newe=0, newd=0; + unsigned long long subindex; // needs to be long cos we lewt shift by alot vector<int> subindices; @@ -262,14 +263,14 @@ vertexb.push_back((params[i]/(1 << blev)) % 2); } - printBool(vertexb); + //printBool(vertexb); vertex = bin2dec(vertexb); - cout << "INV vertex: " << vertex << "\n"; + //cout << "INV vertex: " << vertex << "\n"; // rotate it vertex = rotate(vertex,entryPoint,direction); // % get new index of thisun - cout << "INV rotated: " << vertex << "\n"; + //cout << "INV rotated: " << vertex << "\n"; for(i=0;i<codeLength;i++){ @@ -277,7 +278,7 @@ subindex = i; } } - cout << "INV subindex: " << subindex << "\n"; + //cout << "INV subindex: " << subindex << "\n"; // work out next rotations newe = entryVertices5[subindex]; newd = rotations5[subindex]; @@ -289,7 +290,7 @@ // now build up h from subindices h += subindex << (blev*P); - cout << "------------\n"; + //cout << "------------\n"; } return h;