What formula can I use to create regions in a 3d grid?
Imagine a rubix cube. The cube as a whole is the entire 3d grid, and each mini cube is a region represented by an id.
The grid will be uniform, as well as the regions.
So for example, lets say the max grid size would be 100 x 100 x 100 (50 in positive and 50 in negative) and each region is 10 x 10 x 10.
What formula can I use to determine which region I am in based on my vector3?
I will also need to know what values that region represents.
So, for example, lets say I am given the region id of 5, I need to be able to reverse the formula to be given the min x y z vector (I can calculate the max based on the min).
The result will need to be consistent.
Any help is appreciated!