Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. uint64_t ccSpaceCurveMap3D21Bits64( uint64_t *point )
  2. {
  3. int bit, rotation;
  4. uint64_t curveindex, pointindex, indexpart;
  5. uint64_t addmask, addbits;
  6. pointindex = point[2] ^ ( point[2] >> 1 );
  7. pointindex <<= 21;
  8. pointindex |= point[1] ^ ( point[1] >> 1 );
  9. pointindex <<= 21;
  10. pointindex |= point[0] ^ ( point[0] >> 1 );
  11. rotation = 0;
  12. addmask = 0;
  13. curveindex = 0;
  14. bit = 20;
  15. do
  16. {
  17. indexpart = pointindex >> bit;
  18. addmask ^= ( indexpart & 0x1 ) | ( ( indexpart >> 20 ) & 0x2 ) | ( ( indexpart >> 40 ) & 0x4 );
  19. addbits = ( ( addmask >> rotation ) | ( addmask << ( 3 - rotation ) ) ) & 0x7;
  20. curveindex = ( curveindex << 3 ) | addbits;
  21. addmask = 1 << rotation;
  22. rotation = ( 0x641289 >> ( ( ( addbits & 0x3 ) << 1 ) | ( rotation << 3 ) ) ) & 0x3;
  23. } while( --bit >= 0 );
  24. curveindex ^= (uint64_t)0x924924924924924;
  25. for( bit = 1 ; bit < 63 ; bit <<= 1 )
  26. curveindex ^= curveindex >> bit;
  27. return curveindex;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement