z-order-curve

How to de-interleave bits (UnMortonizing?)

早过忘川 提交于 2019-11-27 12:06:51
What is the most efficient way to de-interleave bits from a 32 bit int? For this particular case, I'm only concerned about the odd bits, although I'm sure it's simple to generalize any solution to both sets. For example, I want to convert 0b01000101 into 0b1011 . What's the quickest way? EDIT: In this application, I can guarantee that the even bits are all zeros. Can I take advantage of that fact to improve speed or reduce space? Given that you know that every other bit is 0 in your application, you can do it like this: x = (x | (x >> 1)) & 0x33333333; x = (x | (x >> 2)) & 0x0f0f0f0f; x = (x |

How to compute a 3D Morton number (interleave the bits of 3 ints)

若如初见. 提交于 2019-11-27 06:20:58
I'm looking for a fast way to compute a 3D Morton number. This site has a magic-number based trick for doing it for 2D Morton numbers, but it doesn't seem obvious how to extend it to 3D. So basically I have 3 10-bit numbers that I want to interleave into a single 30 bit number with a minimal number of operations. You can use the same technique. I'm assuming that variables contain 32-bit integers with the highest 22 bits set to 0 (which is a bit more restrictive than necessary). For each variable x containing one of the three 10-bit integers we do the following: x = (x | (x << 16)) & 0x030000FF

How to de-interleave bits (UnMortonizing?)

笑着哭i 提交于 2019-11-26 22:21:57
问题 What is the most efficient way to de-interleave bits from a 32 bit int? For this particular case, I'm only concerned about the odd bits, although I'm sure it's simple to generalize any solution to both sets. For example, I want to convert 0b01000101 into 0b1011 . What's the quickest way? EDIT: In this application, I can guarantee that the even bits are all zeros. Can I take advantage of that fact to improve speed or reduce space? 回答1: Given that you know that every other bit is 0 in your

How to efficiently de-interleave bits (inverse Morton)

微笑、不失礼 提交于 2019-11-26 20:13:29
问题 This question: How to de-interleave bits (UnMortonizing?) has a good answer for extracting one of the two halves of a Morton number (just the odd bits), but I need a solution which extracts both parts (the odd bits and the even bits) in as few operations as possible. For my use I would need to take a 32 bit int and extract two 16 bit ints, where one is the even bits and the other is the odd bits shifted right by 1 bit, e.g. input, z: 11101101 01010111 11011011 01101110 output, x: 11100001

How to compute a 3D Morton number (interleave the bits of 3 ints)

萝らか妹 提交于 2019-11-26 11:57:02
问题 I\'m looking for a fast way to compute a 3D Morton number. This site has a magic-number based trick for doing it for 2D Morton numbers, but it doesn\'t seem obvious how to extend it to 3D. So basically I have 3 10-bit numbers that I want to interleave into a single 30 bit number with a minimal number of operations. 回答1: You can use the same technique. I'm assuming that variables contain 32-bit integers with the highest 22 bits set to 0 (which is a bit more restrictive than necessary). For