Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A question about the z_order.py #120

Open
Exbilar opened this issue Dec 13, 2024 · 4 comments
Open

A question about the z_order.py #120

Exbilar opened this issue Dec 13, 2024 · 4 comments

Comments

@Exbilar
Copy link

Exbilar commented Dec 13, 2024

Hey there, thanks for your great contribution. I am reading the code about serialization, and I found the code snipt here in z_order.py:

    def xyz2key(self, x, y, z, depth):
        key = torch.zeros_like(x)
        for i in range(depth):
            mask = 1 << i
            key = (
                key
                | ((x & mask) << (2 * i + 2))
                | ((y & mask) << (2 * i + 1))
                | ((z & mask) << (2 * i + 0))
            )
        return key

I am confused why you are using 2 * i here, and I suppose it might be 3 * i here. Thanks for your answering!

@ListIndexOutOfRange
Copy link

Hey,

I'm not the author of the code but I believe this function is correct. The variable i here loops through the bits, it must take successive power of two.

@Exbilar
Copy link
Author

Exbilar commented Dec 13, 2024

Hi,

Thanks for your answering! I am not very familiar with the z-ordering curve. My understanding is for coordinates (X,Y,Z)
X = (..., x2, x1, x0)
Y = (..., y2, y1, y0)
Z = (..., z2, x1, z0)

the encoded key value is Key = (..., x2, y2, z2, x1, y1, z1, x0, y0, z0)

So I suppose it is 3 * i here, or do I have mistaken somewhere?

@ListIndexOutOfRange
Copy link

No it doesn't work like that, it uses a binary representation. If you encode a point clouds (N, 3), the key is a sequence of N integers, each of them corresponding to the value of the interleaved bits. It leverages discretize 3D space and a specific ordering in order to assign a single integer to a 3D coordinate.

@Exbilar
Copy link
Author

Exbilar commented Dec 13, 2024

Forgive my poor writting, I mean the key = (..., x2, y2, z2, x1, y1, z1, x0, y0, z0) is a binary representation, while
X = (..., x2, x1, x0)
Y = (..., y2, y1, y0)
Z = (..., z2, x1, z0)
are the binary represention of X, Y, Z, they are all integers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants