Index arithmetic – Fast converting index to 3D coordinates

To:

x = index % 3;
y = index / 3  % 3;
z = index / 9;

Back:

index = ((z) * 3 + y) * 3 + x;

Browse More Popular Posts

Leave a Comment