Project

General

Profile

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

magiccube / src / main / java / org / distorted / objects / RubikPyraminx.java @ ad38d800

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 40ab026e Leszek Koltunski
import org.distorted.library.effect.VertexEffectDeform;
27
import org.distorted.library.effect.VertexEffectMove;
28
import org.distorted.library.effect.VertexEffectRotate;
29
import org.distorted.library.effect.VertexEffectScale;
30 f0fa83ae Leszek Koltunski
import org.distorted.library.effect.VertexEffectSink;
31 e844c116 Leszek Koltunski
import org.distorted.library.main.DistortedEffects;
32
import org.distorted.library.main.DistortedTexture;
33
import org.distorted.library.mesh.MeshBase;
34 988f434e Leszek Koltunski
import org.distorted.library.mesh.MeshJoined;
35 e844c116 Leszek Koltunski
import org.distorted.library.mesh.MeshRectangles;
36 988f434e Leszek Koltunski
import org.distorted.library.mesh.MeshTriangles;
37
import org.distorted.library.type.Static1D;
38 e844c116 Leszek Koltunski
import org.distorted.library.type.Static3D;
39
import org.distorted.library.type.Static4D;
40
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42
43
public class RubikPyraminx extends RubikObject
44
{
45 9f4c44fe Leszek Koltunski
  private static final float SQ2 = (float)Math.sqrt(2);
46
  private static final float SQ3 = (float)Math.sqrt(3);
47 10585385 Leszek Koltunski
  private static final float SQ6 = (float)Math.sqrt(6);
48 9f4c44fe Leszek Koltunski
49 ad38d800 Leszek Koltunski
  static final Static3D[] ROT_AXIS = new Static3D[]
50 e844c116 Leszek Koltunski
         {
51 9f4c44fe Leszek Koltunski
           new Static3D(         0,        1,       0 ),
52 49f67f9b Leszek Koltunski
           new Static3D(         0,  -1.0f/3, 2*SQ2/3 ),
53 9f4c44fe Leszek Koltunski
           new Static3D(-SQ2*SQ3/3,  -1.0f/3,  -SQ2/3 ),
54 49f67f9b Leszek Koltunski
           new Static3D( SQ2*SQ3/3,  -1.0f/3,  -SQ2/3 )
55 e844c116 Leszek Koltunski
         };
56
57 ad38d800 Leszek Koltunski
  static final Static3D[] FACE_AXIS = new Static3D[]
58
         {
59
           new Static3D(         0,      -1,       0 ),
60
           new Static3D(         0,  1.0f/3,-2*SQ2/3 ),
61
           new Static3D( SQ2*SQ3/3,  1.0f/3,   SQ2/3 ),
62
           new Static3D(-SQ2*SQ3/3,  1.0f/3,   SQ2/3 )
63
         };
64
65 e844c116 Leszek Koltunski
  private static final int[] FACE_COLORS = new int[]
66
         {
67 ad38d800 Leszek Koltunski
           0xff00ff00, 0xffffff00,  // FACE_AXIS[0] (GREEN ) FACE_AXIS[1] (YELLOW )
68
           0xff0000ff, 0xffff0000   // FACE_AXIS[2] (BLUE  ) FACE_AXIS[3] (RED    )
69 e844c116 Leszek Koltunski
         };
70
71 9f4c44fe Leszek Koltunski
  // computed with res/raw/compute_quats.c
72 10585385 Leszek Koltunski
  private static final Static4D[] QUATS = new Static4D[]
73 e844c116 Leszek Koltunski
         {
74 10585385 Leszek Koltunski
           new Static4D(  0.0f,   0.0f,   0.0f,  1.0f),
75
           new Static4D(  0.0f,  SQ3/2,   0.0f,  0.5f),
76
           new Static4D( SQ2/2, -SQ3/6, -SQ6/6,  0.5f),
77
           new Static4D(-SQ2/2, -SQ3/6, -SQ6/6,  0.5f),
78
           new Static4D(  0.0f, -SQ3/6,  SQ6/3,  0.5f),
79
           new Static4D(  0.0f,  SQ3/2,   0.0f, -0.5f),
80
           new Static4D( SQ2/2, -SQ3/6, -SQ6/6, -0.5f),
81
           new Static4D(-SQ2/2, -SQ3/6, -SQ6/6, -0.5f),
82
           new Static4D(  0.0f, -SQ3/6,  SQ6/3, -0.5f),
83
           new Static4D( SQ2/2, -SQ3/3,  SQ6/6,  0.0f),
84
           new Static4D(  0.0f, -SQ3/3, -SQ6/3,  0.0f),
85
           new Static4D(-SQ2/2, -SQ3/3,  SQ6/6,  0.0f)
86 e844c116 Leszek Koltunski
         };
87
88 89a11f7b Leszek Koltunski
  private int[] mRotArray;
89 40ab026e Leszek Koltunski
  private static VertexEffectRotate[] ROTATION;
90
91
  private static MeshBase mMesh =null;
92 ad38d800 Leszek Koltunski
  private static MeshBase[] mMeshRotated = new MeshBase[ROT_AXIS.length];
93 89a11f7b Leszek Koltunski
94
  static
95
    {
96
    Static3D center = new Static3D(0,0,0);
97
    Static1D angle  = new Static1D(180.0f);
98
99 ad38d800 Leszek Koltunski
    ROTATION = new VertexEffectRotate[ROT_AXIS.length];
100 89a11f7b Leszek Koltunski
101 ad38d800 Leszek Koltunski
    for(int i = 0; i< ROT_AXIS.length; i++)
102 89a11f7b Leszek Koltunski
      {
103 ad38d800 Leszek Koltunski
      ROTATION[i] = new VertexEffectRotate( angle, ROT_AXIS[i], center);
104 40ab026e Leszek Koltunski
      mMeshRotated[i] = null;
105 89a11f7b Leszek Koltunski
      }
106
    }
107 49f67f9b Leszek Koltunski
108 e844c116 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
109
110 4da7d87a Leszek Koltunski
  RubikPyraminx(int size, Static4D quat, DistortedTexture texture,
111 5b893eee Leszek Koltunski
                MeshRectangles mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
112 e844c116 Leszek Koltunski
    {
113 5b893eee Leszek Koltunski
    super(size, 30, quat, texture, mesh, effects, moves, RubikObjectList.PYRA, res, scrWidth);
114 e844c116 Leszek Koltunski
    }
115
116
///////////////////////////////////////////////////////////////////////////////////////////////////
117
118 89a11f7b Leszek Koltunski
  private void emitRow(float x, float y, float z, float dx, float dy, float dz, int n, int rot, Static3D[] array, int index)
119 49f67f9b Leszek Koltunski
    {
120
    for(int i=0; i<n; i++)
121
      {
122
      mRotArray[i+index] = rot;
123
      array[i+index] = new Static3D(x+0.5f,y+SQ2*SQ3/12,z+SQ3/6);
124
      x += dx;
125
      y += dy;
126
      z += dz;
127
      }
128
    }
129
130
///////////////////////////////////////////////////////////////////////////////////////////////////
131
132
  private int emitLowermost(float x, float y, float z, int n, Static3D[] array)
133
    {
134
    int added = 0;
135
136 769409d2 Leszek Koltunski
    emitRow( x      +0.5f, y+SQ3*SQ2/9, z+ SQ3/18,  1.0f, 0,     0, n-1, 1, array, added);
137
    added += (n-1);
138
    emitRow( x    +1.0f/3, y+SQ3*SQ2/9, z+2*SQ3/9,  0.5f, 0, SQ3/2, n-1, 3, array, added);
139
    added += (n-1);
140
    emitRow( x+n-1-1.0f/3, y+SQ3*SQ2/9, z+2*SQ3/9, -0.5f, 0, SQ3/2, n-1, 2, array, added);
141
    added += (n-1);
142
143 49f67f9b Leszek Koltunski
    for(int i=n; i>=1; i--)
144
      {
145 769409d2 Leszek Koltunski
      emitRow(x     , y, z      , 1,0,0, i  , -1, array, added);
146 49f67f9b Leszek Koltunski
      added += i;
147 769409d2 Leszek Koltunski
      emitRow(x+0.5f, y, z+SQ3/6, 1,0,0, i-1,  0, array, added);
148
      added += (i-1);
149 49f67f9b Leszek Koltunski
      x += 0.5f;
150
      y += 0.0f;
151
      z += SQ3/2;
152
      }
153
154
    return added;
155
    }
156
157
///////////////////////////////////////////////////////////////////////////////////////////////////
158
159
  private int emitUpper(float x, float y, float z, int n, Static3D[] array, int index)
160
    {
161
    if( n>1 )
162
      {
163 769409d2 Leszek Koltunski
      emitRow( x           , y          , z        ,  1.0f, 0,     0, n-1, -1, array, index);
164
      index += (n-1);
165
      emitRow( x+0.5f      , y+SQ3*SQ2/9, z+SQ3/18 ,  1.0f, 0,     0, n-1,  1, array, index);
166
      index += (n-1);
167
      emitRow( x+0.5f      , y          , z+SQ3/2  ,  0.5f, 0, SQ3/2, n-1, -1, array, index);
168
      index += (n-1);
169
      emitRow( x    +1.0f/3, y+SQ3*SQ2/9, z+2*SQ3/9,  0.5f, 0, SQ3/2, n-1,  3, array, index);
170 49f67f9b Leszek Koltunski
      index += (n-1);
171 769409d2 Leszek Koltunski
      emitRow( x+n-1       , y          , z        , -0.5f, 0, SQ3/2, n-1, -1, array, index);
172 49f67f9b Leszek Koltunski
      index += (n-1);
173 769409d2 Leszek Koltunski
      emitRow( x+n-1-1.0f/3, y+SQ3*SQ2/9, z+2*SQ3/9, -0.5f, 0, SQ3/2, n-1,  2, array, index);
174 49f67f9b Leszek Koltunski
      index += (n-1);
175
      }
176
    else
177
      {
178 89a11f7b Leszek Koltunski
      mRotArray[index] = -1;
179 49f67f9b Leszek Koltunski
      array[index] = new Static3D(x+0.5f,y+SQ2*SQ3/12,z+SQ3/6);
180
      index++;
181
      }
182
183
    return index;
184
    }
185
186
///////////////////////////////////////////////////////////////////////////////////////////////////
187
// size^2 + 3*(size-1) in the lowermost layer, then 6*(size-2) in the next, 6*(size-3) in the next,
188
// ... 6 in the forelast, 1 in the last = 4size^2 - 6size +4 (if size>1)
189
190 e844c116 Leszek Koltunski
  Static3D[] getCubitPositions(int size)
191
    {
192 769409d2 Leszek Koltunski
    int numCubits = size>1 ? 4*size*size - 6*size +4 : 1;
193 c2cb520d Leszek Koltunski
    Static3D[] tmp = new Static3D[numCubits];
194 89a11f7b Leszek Koltunski
    mRotArray = new int[numCubits];
195 49f67f9b Leszek Koltunski
196
    int currentIndex = emitLowermost( -0.5f*size, -(SQ2*SQ3/12)*size, -(SQ3/6)*size, size, tmp);
197 c2cb520d Leszek Koltunski
198 49f67f9b Leszek Koltunski
    for(int i=size-1; i>=1; i--)
199 cc7dc72a Leszek Koltunski
      {
200 49f67f9b Leszek Koltunski
      currentIndex = emitUpper( -0.5f*i, ((SQ2*SQ3)/12)*(3*size-4*i), -(SQ3/6)*i, i, tmp, currentIndex);
201 cc7dc72a Leszek Koltunski
      }
202 49f67f9b Leszek Koltunski
203 c2cb520d Leszek Koltunski
    return tmp;
204 e844c116 Leszek Koltunski
    }
205
206
///////////////////////////////////////////////////////////////////////////////////////////////////
207
208 10585385 Leszek Koltunski
  Static4D[] getQuats()
209 e844c116 Leszek Koltunski
    {
210 10585385 Leszek Koltunski
    return QUATS;
211 e844c116 Leszek Koltunski
    }
212
213
///////////////////////////////////////////////////////////////////////////////////////////////////
214
215
  int getNumFaces()
216
    {
217
    return FACE_COLORS.length;
218
    }
219
220 8f53e513 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
221
222
  int getNumCubitFaces()
223
    {
224
    return FACE_COLORS.length;
225
    }
226
227 f0fa83ae Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
228
229
  float getScreenRatio()
230
    {
231 7381193e Leszek Koltunski
    return 0.82f;
232 f0fa83ae Leszek Koltunski
    }
233
234 f6d06256 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
235
236
  int getFaceColor(int cubit, int cubitface, int size)
237
    {
238
    boolean belongs = isOnFace(cubit, cubitface, 0 );
239
    return belongs ? cubitface : NUM_FACES;
240
    }
241
242 f0fa83ae Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
243
244 14bd7976 Leszek Koltunski
  private MeshBase createStaticMesh(int cubit)
245 e844c116 Leszek Koltunski
    {
246 40ab026e Leszek Koltunski
    final float SQ2 = (float)Math.sqrt(2);
247
    final float SQ3 = (float)Math.sqrt(3);
248 988f434e Leszek Koltunski
    final float angleFaces = (float)((180/Math.PI)*(2*Math.asin(SQ3/3))); // angle between two faces of a tetrahedron
249
    final int MESHES=4;
250
251 40ab026e Leszek Koltunski
    int association = 1;
252 988f434e Leszek Koltunski
    MeshBase[] meshes = new MeshTriangles[MESHES];
253
254 fbca0033 Leszek Koltunski
    meshes[0] = new MeshTriangles(9);
255 e82f3f9c Leszek Koltunski
    meshes[0].setEffectAssociation(0,association,0);
256 988f434e Leszek Koltunski
257 40ab026e Leszek Koltunski
    for(int i=1; i<MESHES; i++)
258
      {
259
      association <<= 1;
260
      meshes[i] = meshes[0].copy(true);
261 e82f3f9c Leszek Koltunski
      meshes[i].setEffectAssociation(0,association,0);
262 40ab026e Leszek Koltunski
      }
263 988f434e Leszek Koltunski
264 40ab026e Leszek Koltunski
    MeshBase result = new MeshJoined(meshes);
265
266
    Static3D a0 = new Static3D(         0,        1,       0 );
267
    Static3D a1 = new Static3D(         0,  -1.0f/3, 2*SQ2/3 );
268
    Static3D a2 = new Static3D(-SQ2*SQ3/3,  -1.0f/3,  -SQ2/3 );
269
    Static3D a3 = new Static3D( SQ2*SQ3/3,  -1.0f/3,  -SQ2/3 );
270
271
    float tetraHeight = SQ2*SQ3/3;
272
    float d1 = 0.75f*tetraHeight;
273
    float d2 =-0.10f*tetraHeight;
274
    float d3 = 0.20f*tetraHeight;
275
276
    Static3D dCen0 = new Static3D( d1*a0.get0(), d1*a0.get1(), d1*a0.get2() );
277
    Static3D dCen1 = new Static3D( d1*a1.get0(), d1*a1.get1(), d1*a1.get2() );
278
    Static3D dCen2 = new Static3D( d1*a2.get0(), d1*a2.get1(), d1*a2.get2() );
279
    Static3D dCen3 = new Static3D( d1*a3.get0(), d1*a3.get1(), d1*a3.get2() );
280
281
    Static3D dVec0 = new Static3D( d2*a0.get0(), d2*a0.get1(), d2*a0.get2() );
282
    Static3D dVec1 = new Static3D( d2*a1.get0(), d2*a1.get1(), d2*a1.get2() );
283
    Static3D dVec2 = new Static3D( d2*a2.get0(), d2*a2.get1(), d2*a2.get2() );
284
    Static3D dVec3 = new Static3D( d2*a3.get0(), d2*a3.get1(), d2*a3.get2() );
285
286
    Static4D dReg  = new Static4D(0,0,0,d3);
287
    Static1D dRad  = new Static1D(1);
288
289
    Static1D angle  = new Static1D(angleFaces);
290
    Static3D axis1  = new Static3D(  -1, 0,      0);
291
    Static3D axis2  = new Static3D(0.5f, 0, -SQ3/2);
292
    Static3D axis3  = new Static3D(0.5f, 0, +SQ3/2);
293
    Static3D center1= new Static3D(0,-SQ3*SQ2/12,-SQ3/6);
294
    Static3D center2= new Static3D(0,-SQ3*SQ2/12,+SQ3/3);
295
296 14bd7976 Leszek Koltunski
    Static3D center = new Static3D(0,0,0);
297
    Static4D region = new Static4D(0,0,0,0.6f);
298
299 e82f3f9c Leszek Koltunski
    VertexEffectScale   effect1 = new VertexEffectScale ( new Static3D(1,SQ3/2,1) );
300 40ab026e Leszek Koltunski
    VertexEffectRotate  effect2 = new VertexEffectRotate( new Static1D(90), new Static3D(1,0,0), new Static3D(0,0,0) );
301 e82f3f9c Leszek Koltunski
    VertexEffectMove    effect3 = new VertexEffectMove  ( new Static3D(0,-SQ3*SQ2/12,SQ3/12) );
302 40ab026e Leszek Koltunski
    VertexEffectRotate  effect4 = new VertexEffectRotate( new Static1D(180), new Static3D(0,0,1), center1 );
303
    VertexEffectRotate  effect5 = new VertexEffectRotate( angle, axis1, center1 );
304
    VertexEffectRotate  effect6 = new VertexEffectRotate( angle, axis2, center2 );
305
    VertexEffectRotate  effect7 = new VertexEffectRotate( angle, axis3, center2 );
306
307 e82f3f9c Leszek Koltunski
    VertexEffectDeform  effect8 = new VertexEffectDeform(dVec0, dRad, dCen0, dReg);
308
    VertexEffectDeform  effect9 = new VertexEffectDeform(dVec1, dRad, dCen1, dReg);
309
    VertexEffectDeform  effect10= new VertexEffectDeform(dVec2, dRad, dCen2, dReg);
310
    VertexEffectDeform  effect11= new VertexEffectDeform(dVec3, dRad, dCen3, dReg);
311 40ab026e Leszek Koltunski
312 e82f3f9c Leszek Koltunski
    VertexEffectSink    effect12= new VertexEffectSink( new Static1D(1.3f), center, region );
313 14bd7976 Leszek Koltunski
314 e82f3f9c Leszek Koltunski
    effect4.setMeshAssociation(14,-1);  // apply to mesh[1], [2] and [3]
315
    effect5.setMeshAssociation( 2,-1);  // apply only to mesh[1]
316
    effect6.setMeshAssociation( 4,-1);  // apply only to mesh[2]
317
    effect7.setMeshAssociation( 8,-1);  // apply only to mesh[3]
318 40ab026e Leszek Koltunski
319
    result.apply(effect1);
320
    result.apply(effect2);
321
    result.apply(effect3);
322
    result.apply(effect4);
323
    result.apply(effect5);
324
    result.apply(effect6);
325
    result.apply(effect7);
326
    result.apply(effect8);
327
    result.apply(effect9);
328
    result.apply(effect10);
329
    result.apply(effect11);
330 14bd7976 Leszek Koltunski
    result.apply(effect12);
331 89a11f7b Leszek Koltunski
332
    if( mRotArray[cubit]>=0 )
333
      {
334
      result.apply( ROTATION[mRotArray[cubit]] );
335
      }
336
337 470820a7 Leszek Koltunski
    result.mergeEffComponents();
338
339 89a11f7b Leszek Koltunski
    return result;
340 e844c116 Leszek Koltunski
    }
341
342 40ab026e Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
343
344 14bd7976 Leszek Koltunski
  MeshBase createCubitMesh(int cubit)
345 40ab026e Leszek Koltunski
    {
346
    int kind = mRotArray[cubit];
347
348
    if( kind>=0 )
349
      {
350 14bd7976 Leszek Koltunski
      if( mMeshRotated[kind]==null ) mMeshRotated[kind] = createStaticMesh(cubit);
351 470820a7 Leszek Koltunski
      return mMeshRotated[kind].copy(true);
352 40ab026e Leszek Koltunski
      }
353
    else
354
      {
355 14bd7976 Leszek Koltunski
      if( mMesh==null ) mMesh = createStaticMesh(cubit);
356 470820a7 Leszek Koltunski
      return mMesh.copy(true);
357 40ab026e Leszek Koltunski
      }
358
    }
359
360 7289fd6c Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
361
362
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top, int side)
363
    {
364
    float STROKE = 0.06f*side;
365
    float OFF = STROKE/2 -1;
366
    float OFF2 = 0.5f*side + OFF;
367
    float HEIGHT = side - OFF;
368
    float RADIUS = side/12.0f;
369
    float ARC1_H = 0.2f*side;
370
    float ARC1_W = side*0.5f;
371
    float ARC2_W = 0.153f*side;
372
    float ARC2_H = 0.905f*side;
373
    float ARC3_W = side-ARC2_W;
374
375
    paint.setAntiAlias(true);
376
    paint.setStrokeWidth(STROKE);
377
    paint.setColor(FACE_COLORS[face]);
378
    paint.setStyle(Paint.Style.FILL);
379
380
    canvas.drawRect(left,top,left+side,top+side,paint);
381
382 14bd7976 Leszek Koltunski
    paint.setColor(INTERIOR_COLOR);
383 7289fd6c Leszek Koltunski
    paint.setStyle(Paint.Style.STROKE);
384
385
    canvas.drawLine(           left, HEIGHT,  side       +left, HEIGHT, paint);
386
    canvas.drawLine(      OFF +left, side  ,       OFF2  +left,      0, paint);
387
    canvas.drawLine((side-OFF)+left, side  , (side-OFF2) +left,      0, paint);
388
389
    canvas.drawArc( ARC1_W-RADIUS+left, ARC1_H-RADIUS, ARC1_W+RADIUS+left, ARC1_H+RADIUS, 225, 90, false, paint);
390
    canvas.drawArc( ARC2_W-RADIUS+left, ARC2_H-RADIUS, ARC2_W+RADIUS+left, ARC2_H+RADIUS, 105, 90, false, paint);
391
    canvas.drawArc( ARC3_W-RADIUS+left, ARC2_H-RADIUS, ARC3_W+RADIUS+left, ARC2_H+RADIUS, 345, 90, false, paint);
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
///////////////////////////////////////////////////////////////////////////////////////////////////
410 8bbac3c2 Leszek Koltunski
// I don't quite understand it, but 0.82 works better than the theoretically correct SQ3/2 ( 0.866 )
411 39e74052 Leszek Koltunski
412 9621255f Leszek Koltunski
  public float returnMultiplier()
413 39e74052 Leszek Koltunski
    {
414 8bbac3c2 Leszek Koltunski
    return getSize()/0.82f;//(SQ3/2);
415 39e74052 Leszek Koltunski
    }
416 e46e17fb Leszek Koltunski
417 5cf34c5f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
418
419
  public float[] getRowChances()
420
    {
421
    int size = getSize();
422
    int total = size*(size+1)/2;
423
    float running=0.0f;
424
    float[] chances = new float[size];
425
426
    for(int i=0; i<size; i++)
427
      {
428
      running += (size-i);
429
      chances[i] = running / total;
430
      }
431
432
    return chances;
433
    }
434
435 e46e17fb Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
436
437
  public float returnRotationFactor(float offset)
438
    {
439
    int size = getSize();
440
    int row  = (int)(size*offset/(SQ3/2));
441
442
    return ((float)size)/(size-row);
443
    }
444 f0336037 Leszek Koltunski
445
///////////////////////////////////////////////////////////////////////////////////////////////////
446 418aa554 Leszek Koltunski
// TODO  (only needed for solvers - there are no Pyraminx solvers ATM)
447 f0336037 Leszek Koltunski
448 20931cf6 Leszek Koltunski
  public String retObjectString()
449 f0336037 Leszek Koltunski
    {
450
    return "";
451
    }
452 e844c116 Leszek Koltunski
}