TTerraInterlace
Product

Product features · Morton grid indexing

01

Interleave two nonnegative integer grid coordinates into a Morton index with a declared bit width.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Morton grid indexing

● ● ●TerraInterlace●
A concrete starting point · Morton grid indexing ×
def morton2(x, y, bits):
    if type(bits) is not int or not 1 <= bits <= 16:
        raise ValueError("bits.range")
    if any(type(v) is not int or not 0 <= v < (1 << bits)
           for v in (x, y)):
        raise ValueError("coordinate.range")
    result = 0
    for i in range(bits):
        result |= ((x >> i) & 1) << (2 * i)
        result |= ((y >> i) & 1) << (2 * i + 1)
    return result
✳Interleave two nonnegative integer grid coordinates into a Morton index with a declared bit width.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗