Function bitwise::word::morton::decode_2d [] [src]

pub fn decode_2d<T: Word>(v: T) -> (T, T)

Decodes an interleaved Morton index for a Z-Curve into two-dimensional coordinates.

Using _.i to denote the i-th bit in a word, this function decodes the following bit pattern of v:

v = |y.N|x.N|...|y.1|x.1|y.0|x.0|

where N == T::bit_size() / 2,

into the coordinates x and y with the following bit pattern:

x: |...0|x.N|...|x.1|x.0| y: |...0|y.N|...|y.1|y.0|

Example

use bitwise::word::morton;

let x = 0b0000_1010u8;
let y = 0b0000_0011u8;
let r = 0b01_00_11_10u8;
assert_eq!(morton::decode_2d(r), (x, y));