pub fn swizzle(index: usize, num_steps: usize, step_length: u32) -> Coords2dExpand description
Maps a linear index to 2D zigzag coordinates (x, y) within horizontal or vertical strips.
Each strip is made of num_steps steps, each of length step_length.
Strips alternate direction: even strips go top-down, odd strips bottom-up.
Steps alternate direction: even steps go left-to-right, odd steps right-to-left.
- Prefer odd
num_stepsfor smoother transitions between strips. - Prefer power-of-two
step_lengthfor better performance.
§Parameters
index: linear input indexnum_steps: number of snaking steps in a stripstep_length: number of elements in each step (must be > 0)
§Returns
(x, y) coordinates after swizzling