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

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

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

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

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

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

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

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

Note: the decoded coordinates are always invertible to the morton code using the decode_3d function.

Example

use bitwise::word::morton;

let x = 0b0000_0010u8;
let y = 0b0000_0011u8;
let z = 0b0000_0010u8;
let r = 0b00_111_010u8;
assert_eq!(morton::decode_3d(r), (x, y, z));