Generate Z-Order Curve
Visualize the Z-order (Morton) space-filling curve that maps 2D coordinates to 1D using bit interleaving.
What Is a Z-Order Curve?
Pick an order, hit generate, and watch the Z-curve zigzag through a 2D grid — the recursive Z-pattern that maps grid cells to 1D by interleaving the bits of x and y. Handy when you're working with Morton codes, spatial indexing, or GPU texture layouts and want to see the actual curve instead of imagining it. And everything runs in your browser. Nothing gets uploaded.
Frequently Asked Questions
How does the Z-order curve differ from Hilbert?
Both are space-filling curves, but the Hilbert curve maintains better spatial locality (nearby points on the curve are nearby in 2D). The Z-order curve has jumps but is computationally simpler.
What is bit interleaving?
The Morton code interleaves bits of x and y coordinates: if x=011 and y=101, the Morton code is 100111 (y0,x0,y1,x1,y2,x2).
What are the practical uses?
Z-order curves are used in database indexing (spatial databases), texture mapping in GPUs, and quadtree representations.
Why limit to order 8?
At order 8, the grid is 256×256 with 65,536 cells. Higher orders would be too dense to visualize meaningfully.