110,533
社区成员
发帖
与我相关
我的任务
分享
00 01 02 03 04 05 06
07 08 09 10 11 12 13 14 15
16 17 18 19 20 21 22 23 24 25 26
27 28 29 30 31 32 33 34 35 36 37
38 39 40 41 42 43 44 45 46
47 48 49 50 51 52 53
整个内容无非就是一个int[54] C。
总共有19个旋转点,每个旋转假设为X,它有一个内容索引int[6] Indice。
比如第一个6边形的索引就是 Indice = {00, 01, 02, 10, 09, 08};
旋转就是按内容索引,改变那个int[54] C。
class Hexgons
{
int[] C = new int[54];
public static readonly int[][] Indices = new int[19][]
{
new int[] { 0, 1, 2, 10, 9, 8},
...
new int[] {43, 44, 45, 53, 52, 51},
};
public void RotateCW(int x)
{
int[] indice = Indices[x];
int temp = C[indice.Last()];
for(int i = 1; i < indice.Length; i++)
{
C[indice[i]] = C[indice[i - 1]];
}
C[indice.First()] = temp;
}
}