Project

General

Profile

Download (15.3 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / objects / TwistyPyraminx.java @ 680469e6

1 e844c116 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19
20 1f9772f3 Leszek Koltunski
package org.distorted.objects;
21 e844c116 Leszek Koltunski
22 ccf9fec5 Leszek Koltunski
import android.content.res.Resources;
23 e844c116 Leszek Koltunski
import android.graphics.Canvas;
24
import android.graphics.Paint;
25
26 749ef882 Leszek Koltunski
import org.distorted.helpers.FactoryCubit;
27
import org.distorted.helpers.FactorySticker;
28 e844c116 Leszek Koltunski
import org.distorted.library.main.DistortedEffects;
29
import org.distorted.library.main.DistortedTexture;
30
import org.distorted.library.mesh.MeshBase;
31 efa8aa48 Leszek Koltunski
import org.distorted.library.mesh.MeshSquare;
32 e844c116 Leszek Koltunski
import org.distorted.library.type.Static3D;
33
import org.distorted.library.type.Static4D;
34 6fd4a72c Leszek Koltunski
import org.distorted.main.R;
35 e844c116 Leszek Koltunski
36 7c969a6d Leszek Koltunski
import java.util.Random;
37
38 e844c116 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
39
40 9c2f0c91 Leszek Koltunski
public class TwistyPyraminx extends TwistyObject
41 e844c116 Leszek Koltunski
{
42 ad38d800 Leszek Koltunski
  static final Static3D[] ROT_AXIS = new Static3D[]
43 e844c116 Leszek Koltunski
         {
44 ac940e24 Leszek Koltunski
           new Static3D(     0,-SQ3/3,-SQ6/3),
45
           new Static3D(     0,-SQ3/3,+SQ6/3),
46
           new Static3D(+SQ6/3,+SQ3/3,     0),
47
           new Static3D(-SQ6/3,+SQ3/3,     0),
48 ad38d800 Leszek Koltunski
         };
49
50 e844c116 Leszek Koltunski
  private static final int[] FACE_COLORS = new int[]
51
         {
52 ece1b58d Leszek Koltunski
           COLOR_GREEN , COLOR_YELLOW,
53
           COLOR_BLUE  , COLOR_RED
54 e844c116 Leszek Koltunski
         };
55
56 9f4c44fe Leszek Koltunski
  // computed with res/raw/compute_quats.c
57 10585385 Leszek Koltunski
  private static final Static4D[] QUATS = new Static4D[]
58 e844c116 Leszek Koltunski
         {
59 10585385 Leszek Koltunski
           new Static4D(  0.0f,   0.0f,   0.0f,  1.0f),
60 ac940e24 Leszek Koltunski
           new Static4D(  0.0f,   1.0f,   0.0f,  0.0f),
61
           new Static4D( SQ2/2,   0.5f,   0.0f,  0.5f),
62
           new Static4D(-SQ2/2,   0.5f,   0.0f,  0.5f),
63
           new Static4D(  0.0f,  -0.5f, -SQ2/2,  0.5f),
64
           new Static4D(  0.0f,  -0.5f,  SQ2/2,  0.5f),
65
           new Static4D( SQ2/2,   0.5f,   0.0f, -0.5f),
66
           new Static4D(-SQ2/2,   0.5f,   0.0f, -0.5f),
67
           new Static4D(  0.0f,  -0.5f, -SQ2/2, -0.5f),
68
           new Static4D(  0.0f,  -0.5f,  SQ2/2, -0.5f),
69
           new Static4D( SQ2/2,   0.0f,  SQ2/2,  0.0f),
70
           new Static4D(-SQ2/2,   0.0f,  SQ2/2,  0.0f)
71 e844c116 Leszek Koltunski
         };
72
73 31cd7256 Leszek Koltunski
  private static final double[][] VERTICES_TETRA = new double[][]
74 b1f2ccf5 Leszek Koltunski
          {
75
             {-0.5, SQ2/4, 0.0},
76
             { 0.5, SQ2/4, 0.0},
77
             { 0.0,-SQ2/4, 0.5},
78
             { 0.0,-SQ2/4,-0.5}
79
          };
80
81 31cd7256 Leszek Koltunski
  private static final int[][] VERT_INDEXES_TETRA = new int[][]
82 b1f2ccf5 Leszek Koltunski
          {
83
             {2,1,0},   // counterclockwise!
84 31cd7256 Leszek Koltunski
             {3,0,1},
85 b1f2ccf5 Leszek Koltunski
             {3,2,0},
86 31cd7256 Leszek Koltunski
             {2,3,1}
87 b1f2ccf5 Leszek Koltunski
          };
88
89 31cd7256 Leszek Koltunski
  private static final double[][] VERTICES_OCTA = new double[][]
90 b1f2ccf5 Leszek Koltunski
          {
91
             { 0.5,   0.0, 0.5},
92
             { 0.5,   0.0,-0.5},
93
             {-0.5,   0.0,-0.5},
94
             {-0.5,   0.0, 0.5},
95
             { 0.0, SQ2/2, 0.0},
96
             { 0.0,-SQ2/2, 0.0}
97
          };
98
99 31cd7256 Leszek Koltunski
  private static final int[][] VERT_INDEXES_OCTA = new int[][]
100 b1f2ccf5 Leszek Koltunski
          {
101
             {3,0,4},   // counterclockwise!
102
             {0,1,4},
103
             {1,2,4},
104
             {2,3,4},
105
             {5,0,3},
106
             {5,1,0},
107
             {5,2,1},
108
             {5,3,2}
109
          };
110
111 31cd7256 Leszek Koltunski
  private static final float[][] STICKERS = new float[][]
112
          {
113
             { -0.4330127f, -0.25f, 0.4330127f, -0.25f, 0.0f, 0.5f }
114
          };
115
116
  private static MeshBase[] mMeshes;
117 49f67f9b Leszek Koltunski
118 e844c116 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
119
120 ac940e24 Leszek Koltunski
  TwistyPyraminx(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
121
                 DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
122 e844c116 Leszek Koltunski
    {
123 db875721 Leszek Koltunski
    super(size, size, quat, texture, mesh, effects, moves, ObjectList.PYRA, res, scrWidth);
124 e844c116 Leszek Koltunski
    }
125
126 b1f2ccf5 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
127
128
  double[][] getVertices(int cubitType)
129
    {
130 31cd7256 Leszek Koltunski
    if( cubitType==0 ) return VERTICES_OCTA;
131
    if( cubitType==1 ) return VERTICES_TETRA;
132 b1f2ccf5 Leszek Koltunski
    return null;
133
    }
134
135
///////////////////////////////////////////////////////////////////////////////////////////////////
136
137
  int[][] getVertIndexes(int cubitType)
138
    {
139 31cd7256 Leszek Koltunski
    if( cubitType==0 ) return VERT_INDEXES_OCTA;
140
    if( cubitType==1 ) return VERT_INDEXES_TETRA;
141 b1f2ccf5 Leszek Koltunski
    return null;
142
    }
143
144
///////////////////////////////////////////////////////////////////////////////////////////////////
145
146
  int getNumCubitTypes(int numLayers)
147
    {
148
    return 2;
149
    }
150
151 e844c116 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
152
153 e6cf7283 Leszek Koltunski
  private void addTetrahedralLattice(int size, int index, float[][] pos)
154 49f67f9b Leszek Koltunski
    {
155 ac940e24 Leszek Koltunski
    final float DX = 1.0f;
156
    final float DY = SQ2/2;
157
    final float DZ = 1.0f;
158 49f67f9b Leszek Koltunski
159 ac940e24 Leszek Koltunski
    float startX = 0.0f;
160
    float startY =-DY*(size-1)/2;
161
    float startZ = DZ*(size-1)/2;
162 769409d2 Leszek Koltunski
163 ac940e24 Leszek Koltunski
    for(int layer=0; layer<size; layer++)
164 49f67f9b Leszek Koltunski
      {
165 ac940e24 Leszek Koltunski
      float currX = startX;
166
      float currY = startY;
167
168
      for(int x=0; x<layer+1; x++)
169
        {
170
        float currZ = startZ;
171
172
        for(int z=0; z<size-layer; z++)
173
          {
174 e6cf7283 Leszek Koltunski
          pos[index] = new float[] {currX,currY,currZ};
175 ac940e24 Leszek Koltunski
          index++;
176
          currZ -= DZ;
177
          }
178
179
        currX += DX;
180
        }
181
182
      startX-=DX/2;
183
      startY+=DY;
184
      startZ-=DZ/2;
185 49f67f9b Leszek Koltunski
      }
186
    }
187
188
///////////////////////////////////////////////////////////////////////////////////////////////////
189 ac940e24 Leszek Koltunski
// there are (n^3-n)/6 octahedrons and ((n+1)^3 - (n+1))/6 tetrahedrons
190 49f67f9b Leszek Koltunski
191 e6cf7283 Leszek Koltunski
  float[][] getCubitPositions(int size)
192 e844c116 Leszek Koltunski
    {
193 ac940e24 Leszek Koltunski
    int numOcta = (size-1)*size*(size+1)/6;
194
    int numTetra= size*(size+1)*(size+2)/6;
195 e6cf7283 Leszek Koltunski
    float[][] ret = new float[numOcta+numTetra][];
196 49f67f9b Leszek Koltunski
197 ac940e24 Leszek Koltunski
    addTetrahedralLattice(size-1,      0,ret);
198
    addTetrahedralLattice(size  ,numOcta,ret);
199 49f67f9b Leszek Koltunski
200 ac940e24 Leszek Koltunski
    return ret;
201 e844c116 Leszek Koltunski
    }
202
203
///////////////////////////////////////////////////////////////////////////////////////////////////
204
205 10585385 Leszek Koltunski
  Static4D[] getQuats()
206 e844c116 Leszek Koltunski
    {
207 10585385 Leszek Koltunski
    return QUATS;
208 e844c116 Leszek Koltunski
    }
209
210
///////////////////////////////////////////////////////////////////////////////////////////////////
211
212
  int getNumFaces()
213
    {
214
    return FACE_COLORS.length;
215
    }
216
217 eab9d8f8 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
218
219 a64e07d0 Leszek Koltunski
  int getNumStickerTypes(int numLayers)
220 eab9d8f8 Leszek Koltunski
    {
221 31cd7256 Leszek Koltunski
    return STICKERS.length;
222 eab9d8f8 Leszek Koltunski
    }
223
224 7403cdfa Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
225
226 a97e02b7 Leszek Koltunski
  float[] getCuts(int size)
227 7403cdfa Leszek Koltunski
    {
228 a97e02b7 Leszek Koltunski
    float[] cuts = new float[size-1];
229
230
    for(int i=0; i<size-1; i++)
231
      {
232
      cuts[i] = (1.0f-0.25f*size+i)*(SQ6/3);
233
      }
234
235
    return cuts;
236 7403cdfa Leszek Koltunski
    }
237
238 8f53e513 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
239
240
  int getNumCubitFaces()
241
    {
242 ac940e24 Leszek Koltunski
    return 8;
243 8f53e513 Leszek Koltunski
    }
244
245 f0fa83ae Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
246
247
  float getScreenRatio()
248
    {
249 7381193e Leszek Koltunski
    return 0.82f;
250 f0fa83ae Leszek Koltunski
    }
251
252 eaee1ddc Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
253
254
  boolean shouldResetTextureMaps()
255
    {
256
    return false;
257
    }
258
259 31cd7256 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
260
261
  private int getNumOctahedrons(int numLayers)
262
    {
263
    return (numLayers-1)*numLayers*(numLayers+1)/6;
264
    }
265
266 f6d06256 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
267
268 ac940e24 Leszek Koltunski
  private int faceColor(int cubit, int axis)
269 f6d06256 Leszek Koltunski
    {
270 f0450fcc Leszek Koltunski
    return CUBITS[cubit].mRotationRow[axis] == 1 ? axis : NUM_FACES;
271 f6d06256 Leszek Koltunski
    }
272
273 f0fa83ae Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
274
275 ac940e24 Leszek Koltunski
  int getFaceColor(int cubit, int cubitface, int size)
276 e844c116 Leszek Koltunski
    {
277 ac940e24 Leszek Koltunski
    if( cubit< (size-1)*size*(size+1)/6 )
278 40ab026e Leszek Koltunski
      {
279 ac940e24 Leszek Koltunski
      switch( cubitface )
280
        {
281
        case 0: return faceColor(cubit,0);
282
        case 2: return faceColor(cubit,1);
283
        case 5: return faceColor(cubit,3);
284
        case 7: return faceColor(cubit,2);
285
        default:return NUM_FACES;
286
        }
287 40ab026e Leszek Koltunski
      }
288 ac940e24 Leszek Koltunski
    else
289 89a11f7b Leszek Koltunski
      {
290 ac940e24 Leszek Koltunski
      return cubitface<NUM_FACES ? faceColor(cubit,cubitface) : NUM_FACES;
291 89a11f7b Leszek Koltunski
      }
292 e844c116 Leszek Koltunski
    }
293
294 40ab026e Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
295
296 a64e07d0 Leszek Koltunski
  MeshBase createCubitMesh(int cubit, int numLayers)
297 40ab026e Leszek Koltunski
    {
298 31cd7256 Leszek Koltunski
    if( mMeshes==null )
299 40ab026e Leszek Koltunski
      {
300 31cd7256 Leszek Koltunski
      FactoryCubit factory = FactoryCubit.getInstance();
301
      factory.clear();
302
      mMeshes = new MeshBase[2];
303
      }
304
305
    MeshBase mesh;
306
    int numO = getNumOctahedrons(numLayers);
307
308
    if( cubit<numO )
309
      {
310
      if( mMeshes[0]==null )
311
        {
312
        float[][] bands     = new float[][] { {0.05f,35,0.5f,0.8f,6,2,2} };
313
        int[] bandIndexes   = new int[] { 0,0,0,0,0,0,0,0 };
314
        float[][] corners   = new float[][] { {0.04f,0.20f} };
315
        int[] cornerIndexes = new int[] { 0,0,0,0,0,0 };
316 b3c9061a Leszek Koltunski
        float[][] centers   = new float[][] { {0.0f, 0.0f, 0.0f} };
317
        int[] centerIndexes = new int[] { 0,0,0,0,0,0 };
318 31cd7256 Leszek Koltunski
319
        FactoryCubit factory = FactoryCubit.getInstance();
320
321
        factory.createNewFaceTransform(VERTICES_OCTA,VERT_INDEXES_OCTA);
322
        mMeshes[0] = factory.createRoundedSolid(VERTICES_OCTA, VERT_INDEXES_OCTA,
323
                                                bands, bandIndexes,
324
                                                corners, cornerIndexes,
325 b3c9061a Leszek Koltunski
                                                centers, centerIndexes,
326 31cd7256 Leszek Koltunski
                                                getNumCubitFaces() );
327
        }
328
      mesh = mMeshes[0].copy(true);
329 40ab026e Leszek Koltunski
      }
330
    else
331
      {
332 31cd7256 Leszek Koltunski
      if( mMeshes[1]==null )
333
        {
334
        float[][] bands     = new float[][] { {0.05f,35,0.5f,0.8f,6,2,2} };
335
        int[] bandIndexes   = new int[] { 0,0,0,0 };
336
        float[][] corners   = new float[][] { {0.06f,0.15f} };
337
        int[] cornerIndexes = new int[] { 0,0,0,0 };
338 b3c9061a Leszek Koltunski
        float[][] centers   = new float[][] { {0.0f, 0.0f, 0.0f} };
339
        int[] centerIndexes = new int[] { 0,0,0,0 };
340 31cd7256 Leszek Koltunski
341
        FactoryCubit factory = FactoryCubit.getInstance();
342
343
        factory.createNewFaceTransform(VERTICES_TETRA,VERT_INDEXES_TETRA);
344
        mMeshes[1] = factory.createRoundedSolid(VERTICES_TETRA, VERT_INDEXES_TETRA,
345
                                                bands, bandIndexes,
346
                                                corners, cornerIndexes,
347 b3c9061a Leszek Koltunski
                                                centers, centerIndexes,
348 31cd7256 Leszek Koltunski
                                                getNumCubitFaces() );
349
350
        factory.printStickerCoords();
351
        }
352
      mesh = mMeshes[1].copy(true);
353 40ab026e Leszek Koltunski
      }
354 31cd7256 Leszek Koltunski
355
    return mesh;
356 40ab026e Leszek Koltunski
    }
357
358 7289fd6c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
359
360 ae755eda Leszek Koltunski
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
361 7289fd6c Leszek Koltunski
    {
362 76c2bd07 Leszek Koltunski
    float R = 0.06f;
363
    float S = 0.08f;
364
365 b89898c5 Leszek Koltunski
    FactorySticker factory = FactorySticker.getInstance();
366 31cd7256 Leszek Koltunski
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], S, FACE_COLORS[face], R);
367 7289fd6c Leszek Koltunski
    }
368
369 fb377dae Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
370 7403cdfa Leszek Koltunski
// SQ6/3 = height of the tetrahedron
371 fb377dae Leszek Koltunski
372
  float returnMultiplier()
373
    {
374 d99f3a48 Leszek Koltunski
    return getNumLayers()/(SQ6/3);
375 fb377dae Leszek Koltunski
    }
376
377 7c969a6d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
378
379 a64e07d0 Leszek Koltunski
  float[] getRowChances(int numLayers)
380 7c969a6d Leszek Koltunski
    {
381 d99f3a48 Leszek Koltunski
    int total = numLayers*(numLayers+1)/2;
382 7c969a6d Leszek Koltunski
    float running=0.0f;
383 d99f3a48 Leszek Koltunski
    float[] chances = new float[numLayers];
384 7c969a6d Leszek Koltunski
385 d99f3a48 Leszek Koltunski
    for(int i=0; i<numLayers; i++)
386 7c969a6d Leszek Koltunski
      {
387 d99f3a48 Leszek Koltunski
      running += (numLayers-i);
388 7c969a6d Leszek Koltunski
      chances[i] = running / total;
389
      }
390
391
    return chances;
392
    }
393
394 e844c116 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
395
// PUBLIC API
396
397 12ad3fca Leszek Koltunski
  public Static3D[] getRotationAxis()
398
    {
399 ad38d800 Leszek Koltunski
    return ROT_AXIS;
400 12ad3fca Leszek Koltunski
    }
401
402
///////////////////////////////////////////////////////////////////////////////////////////////////
403
404 e844c116 Leszek Koltunski
  public int getBasicAngle()
405
    {
406
    return 3;
407
    }
408 39e74052 Leszek Koltunski
409 7c969a6d Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
410
411 5043d5d0 Leszek Koltunski
  public void randomizeNewScramble(int[][] scramble, Random rnd, int num)
412 7c969a6d Leszek Koltunski
    {
413 5043d5d0 Leszek Koltunski
    if( num==0 )
414 5cf34c5f Leszek Koltunski
      {
415 5043d5d0 Leszek Koltunski
      scramble[num][0] = rnd.nextInt(ROTATION_AXIS.length);
416 7c969a6d Leszek Koltunski
      }
417
    else
418
      {
419 bbc6471c Leszek Koltunski
      int newVector = rnd.nextInt(ROTATION_AXIS.length-1);
420 5043d5d0 Leszek Koltunski
      scramble[num][0] = (newVector>=scramble[num-1][0] ? newVector+1 : newVector);
421 5cf34c5f Leszek Koltunski
      }
422 e46e17fb Leszek Koltunski
423 7c969a6d Leszek Koltunski
    float rowFloat = rnd.nextFloat();
424 e46e17fb Leszek Koltunski
425 7c969a6d Leszek Koltunski
    for(int row=0; row<mRowChances.length; row++)
426
      {
427 bbc6471c Leszek Koltunski
      if( rowFloat<=mRowChances[row] )
428
        {
429 5043d5d0 Leszek Koltunski
        scramble[num][1] = row;
430 bbc6471c Leszek Koltunski
        break;
431
        }
432 7c969a6d Leszek Koltunski
      }
433
434 5043d5d0 Leszek Koltunski
    switch( rnd.nextInt(2) )
435
      {
436
      case 0: scramble[num][2] = -1; break;
437
      case 1: scramble[num][2] =  1; break;
438
      }
439 e46e17fb Leszek Koltunski
    }
440 f0336037 Leszek Koltunski
441 6b6504fe Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
442
443
  public boolean isSolved()
444
    {
445
    int index = CUBITS[0].mQuatIndex;
446
447
    for(int i=1; i<NUM_CUBITS; i++)
448
      {
449 722b2512 Leszek Koltunski
      if( thereIsVisibleDifference(CUBITS[i], index) ) return false;
450 6b6504fe Leszek Koltunski
      }
451
452
    return true;
453
    }
454
455 221a4090 Leszek Koltunski
////////////////////////////////////////////////////////////////////////
456 ee35e63c Leszek Koltunski
// only needed for solvers - there are no Pyraminx solvers ATM)
457 f0336037 Leszek Koltunski
458 20931cf6 Leszek Koltunski
  public String retObjectString()
459 f0336037 Leszek Koltunski
    {
460
    return "";
461
    }
462 6fd4a72c Leszek Koltunski
463
///////////////////////////////////////////////////////////////////////////////////////////////////
464
465
  public int getObjectName(int numLayers)
466
    {
467
    switch(numLayers)
468
      {
469
      case 3: return R.string.pyra3;
470
      case 4: return R.string.pyra4;
471
      case 5: return R.string.pyra5;
472
      }
473
    return R.string.pyra3;
474
    }
475
476
///////////////////////////////////////////////////////////////////////////////////////////////////
477
478
  public int getInventor(int numLayers)
479
    {
480
    switch(numLayers)
481
      {
482
      case 3: return R.string.pyra3_inventor;
483
      case 4: return R.string.pyra4_inventor;
484
      case 5: return R.string.pyra5_inventor;
485
      }
486
    return R.string.pyra3_inventor;
487
    }
488
489
///////////////////////////////////////////////////////////////////////////////////////////////////
490
491
  public int getComplexity(int numLayers)
492
    {
493
    switch(numLayers)
494
      {
495
      case 3: return 4;
496
      case 4: return 6;
497
      case 5: return 8;
498
      }
499
    return 4;
500
    }
501 e844c116 Leszek Koltunski
}