Calculates the path from `current_dim_index` to `target_dim_index`. Decomposes the difference into powers of 4 and returns the indices.
(target_dim_index: u32, current_dim_index: u32)
| 11 | /// Calculates the path from `current_dim_index` to `target_dim_index`. |
| 12 | /// Decomposes the difference into powers of 4 and returns the indices. |
| 13 | pub fn calculate_path(target_dim_index: u32, current_dim_index: u32) -> Vec<u8> { |
| 14 | let mut path = Vec::new(); |
| 15 | let mut remaining = target_dim_index - current_dim_index; |
| 16 | |
| 17 | while remaining > 0 { |
| 18 | let (child_index, pow_4) = largest_power_of_4_below(remaining); |
| 19 | path.push(child_index); |
| 20 | remaining -= pow_4; |
| 21 | } |
| 22 | |
| 23 | path |
| 24 | } |