|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Modulos
Modulos implementations encapsulate algorithms to map between integral ordinals and position arrays. There are particular implementations for the most likely cases where the number of axes is 1, 2 and 3 as well as a general implementation.
Suppose the result is 4 x 3 x 2, then modulo = {1, 4, 12, 24}.
Then the ordinal of cell (3, 2, 1)
= (modulo[0] * 3) + (modulo[1] * 2) + (modulo[2] * 1) = (1 * 3) + (4 * 2) + (12 * 1) = 23
Reverse calculation:
p[0] = (23 % modulo[1]) / modulo[0] = (23 % 4) / 1 = 3 p[1] = (23 % modulo[2]) / modulo[1] = (23 % 12) / 4 = 2 p[2] = (23 % modulo[3]) / modulo[2] = (23 % 24) / 12 = 1
Nested Class Summary | |
---|---|
static class |
Modulos.Base
|
static class |
Modulos.Generator
|
static class |
Modulos.Many
|
static class |
Modulos.One
|
static class |
Modulos.Three
|
static class |
Modulos.Two
|
static class |
Modulos.Zero
|
Method Summary | |
---|---|
int |
getCellOrdinal(int[] pos)
Converts a set of cell coordinates to a cell ordinal. |
int[] |
getCellPos(int cellOrdinal)
Converts a cell ordinal to a set of cell coordinates. |
Method Detail |
---|
int[] getCellPos(int cellOrdinal)
getCellOrdinal(int[])
. For example, if this result is 10 x 10 x 10,
then cell ordinal 537 has coordinates (5, 3, 7).
cellOrdinal
- Cell ordinal
int getCellOrdinal(int[] pos)
getCellPos(int)
.
pos
- Cell coordinates
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |