Project

General

Profile

Download (12.7 KB) Statistics
| Branch: | Revision:

distorted-objectlib / src / main / java / org / distorted / objectlib / objects / TwistyPentultimate.java @ 79bf5a5e

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 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
package org.distorted.objectlib.objects;
21

    
22
import org.distorted.library.type.Static3D;
23
import org.distorted.library.type.Static4D;
24
import org.distorted.objectlib.helpers.ObjectFaceShape;
25
import org.distorted.objectlib.helpers.ObjectShape;
26
import org.distorted.objectlib.main.ObjectType;
27
import org.distorted.objectlib.scrambling.ScrambleState;
28

    
29
import java.io.InputStream;
30

    
31
import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
32
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.C2;
33
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.COS54;
34
import static org.distorted.objectlib.touchcontrol.TouchControlDodecahedron.SIN54;
35

    
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

    
38
public class TwistyPentultimate extends TwistyMinx
39
{
40
  private float[][] mCuts;
41
  private float[][] mPosition;
42
  private int[] mQuatIndex;
43

    
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45

    
46
  public TwistyPentultimate(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
47
    {
48
    super(numL, meshState, iconMode, quat, move, scale, stream);
49
    }
50

    
51
///////////////////////////////////////////////////////////////////////////////////////////////////
52

    
53
  @Override
54
  public ScrambleState[] getScrambleStates()
55
    {
56
    if( mStates==null )
57
      {
58
      int[] ALL = new int[] { 0,-2,0, 0,-1,0, 0,1,0, 0,2,0, 1,-2,0, 1,-1,0, 1,1,0, 1,2,0 };
59

    
60
      mStates = new ScrambleState[]
61
        {
62
        new ScrambleState( new int[][] { ALL,ALL,ALL,ALL,ALL,ALL } )
63
        };
64
      }
65

    
66
    return mStates;
67
    }
68

    
69
///////////////////////////////////////////////////////////////////////////////////////////////////
70

    
71
  @Override
72
  public int getTouchControlSplit()
73
    {
74
    return TYPE_NOT_SPLIT;
75
    }
76

    
77
///////////////////////////////////////////////////////////////////////////////////////////////////
78

    
79
  @Override
80
  public boolean[][] getLayerRotatable(int[] numLayers)
81
    {
82
    boolean[] tmp = new boolean[] {true,true};
83
    return new boolean[][] {tmp,tmp,tmp,tmp,tmp,tmp};
84
    }
85

    
86
///////////////////////////////////////////////////////////////////////////////////////////////////
87

    
88
  @Override
89
  public int[][][] getEnabled()
90
    {
91
    return new int[][][]
92
      {
93
          {{1,2,3,4,5}},
94
          {{0,2,3,4,5}},
95
          {{0,2,3,4,5}},
96
          {{1,2,3,4,5}},
97
          {{0,1,3,4,5}},
98
          {{0,1,2,4,5}},
99
          {{0,1,2,4,5}},
100
          {{0,1,3,4,5}},
101
          {{0,1,2,3,5}},
102
          {{0,1,2,3,4}},
103
          {{0,1,2,3,4}},
104
          {{0,1,2,3,5}},
105
      };
106
    }
107

    
108
///////////////////////////////////////////////////////////////////////////////////////////////////
109

    
110
  public float[][] getCubitPositions(int[] numLayers)
111
    {
112
    if( mPosition==null )
113
      {
114
      if( mCenterCoords==null ) initializeCenterCoords();
115
      final float A = 2.0f/3;
116

    
117
      mPosition = new float[NUM_CORNERS+NUM_CENTERS][3];
118

    
119
      for(int corner=0; corner<NUM_CORNERS; corner++)
120
        {
121
        mPosition[corner][0] = A*mCorners[corner][0];
122
        mPosition[corner][1] = A*mCorners[corner][1];
123
        mPosition[corner][2] = A*mCorners[corner][2];
124
        }
125

    
126
      for(int center=0; center<NUM_CENTERS; center++)
127
        {
128
        int index = center+NUM_CORNERS;
129
        mPosition[index][0] = A*mCenterCoords[center][0];
130
        mPosition[index][1] = A*mCenterCoords[center][1];
131
        mPosition[index][2] = A*mCenterCoords[center][2];
132
        }
133
      }
134

    
135
    return mPosition;
136
    }
137

    
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139

    
140
  public Static4D getCubitQuats(int cubit, int[] numLayers)
141
    {
142
    if( mQuatIndex==null )
143
      {
144
      mQuatIndex = new int[]
145
        {
146
         0, 29, 59, 48, 18, 53, 22, 49, 11, 54,
147
        10, 52, 17, 27, 19, 26,  9, 28, 23, 45,
148

    
149
         0, 59, 15,  6,  4,  3, 29, 10, 35,  8,  2,  5
150
        };
151
      }
152

    
153
    return mObjectQuats[mQuatIndex[cubit]];
154
    }
155

    
156
///////////////////////////////////////////////////////////////////////////////////////////////////
157

    
158
  public ObjectShape getObjectShape(int variant)
159
    {
160
    final float A = 2.0f/3;
161

    
162
    if( variant==0 ) // corner
163
      {
164
      float x0  = A*mCorners[ 0][0];
165
      float x2  = A*mCorners[ 2][0];
166
      float x12 = A*mCorners[12][0];
167
      float x16 = A*mCorners[16][0];
168
      float y0  = A*mCorners[ 0][1];
169
      float y2  = A*mCorners[ 2][1];
170
      float y12 = A*mCorners[12][1];
171
      float y16 = A*mCorners[16][1];
172
      float z0  = A*mCorners[ 0][2];
173
      float z2  = A*mCorners[ 2][2];
174
      float z12 = A*mCorners[12][2];
175
      float z16 = A*mCorners[16][2];
176

    
177
      float[][] vertices =
178
        {
179
            { 0,0,0 },
180
            { (x16-x0)/2, (y16-y0)/2, (z16-z0)/2, },
181
            { (x12-x0)/2, (y12-y0)/2, (z12-z0)/2, },
182
            { (x2 -x0)/2, (y2 -y0)/2, (z2 -z0)/2, },
183
            { 0,-1,-2*C2 },
184
        };
185

    
186
      int[][] indices =
187
        {
188
            {0,1,3},
189
            {0,3,2},
190
            {0,2,1},
191
            {4,3,1},
192
            {4,2,3},
193
            {4,1,2}
194
        };
195

    
196
      return new ObjectShape(vertices, indices);
197
      }
198
    else
199
      {
200
      int i0 = mCenterMap[0][0];
201
      int i1 = mCenterMap[0][1];
202
      int i2 = mCenterMap[0][2];
203
      int i3 = mCenterMap[0][3];
204
      int i4 = mCenterMap[0][4];
205

    
206
      float x0 = A*mCorners[i0][0];
207
      float x1 = A*mCorners[i1][0];
208
      float x2 = A*mCorners[i2][0];
209
      float x3 = A*mCorners[i3][0];
210
      float x4 = A*mCorners[i4][0];
211

    
212
      float y0 = A*mCorners[i0][1];
213
      float y1 = A*mCorners[i1][1];
214
      float y2 = A*mCorners[i2][1];
215
      float y3 = A*mCorners[i3][1];
216
      float y4 = A*mCorners[i4][1];
217

    
218
      float z0 = A*mCorners[i0][2];
219
      float z1 = A*mCorners[i1][2];
220
      float z2 = A*mCorners[i2][2];
221
      float z3 = A*mCorners[i3][2];
222
      float z4 = A*mCorners[i4][2];
223

    
224
      float cx = A*mCenterCoords[0][0];
225
      float cy = A*mCenterCoords[0][1];
226
      float cz = A*mCenterCoords[0][2];
227

    
228
      float X0 = (x0+x1)/2 -cx;
229
      float Y0 = (y0+y1)/2 -cy;
230
      float Z0 = (z0+z1)/2 -cz;
231

    
232
      float X1 = (x1+x2)/2 -cx;
233
      float Y1 = (y1+y2)/2 -cy;
234
      float Z1 = (z1+z2)/2 -cz;
235

    
236
      float X2 = (x2+x3)/2 -cx;
237
      float Y2 = (y2+y3)/2 -cy;
238
      float Z2 = (z2+z3)/2 -cz;
239

    
240
      float X3 = (x3+x4)/2 -cx;
241
      float Y3 = (y3+y4)/2 -cy;
242
      float Z3 = (z3+z4)/2 -cz;
243

    
244
      float X4 = (x4+x0)/2 -cx;
245
      float Y4 = (y4+y0)/2 -cy;
246
      float Z4 = (z4+z0)/2 -cz;
247

    
248
      float X5 = -cx;
249
      float Y5 = -cy;
250
      float Z5 = -cz;
251

    
252
      float[][] vertices =
253
         {
254
             { X0,Y0,Z0 },
255
             { X1,Y1,Z1 },
256
             { X2,Y2,Z2 },
257
             { X3,Y3,Z3 },
258
             { X4,Y4,Z4 },
259
             { X5,Y5,Z5 }
260
         };
261
      int[][] indices =
262
         {
263
             {4,3,2,1,0},
264
             {0,5,1},
265
             {1,5,2},
266
             {2,5,3},
267
             {3,5,4},
268
             {4,5,0}
269
         };
270

    
271
      return new ObjectShape(vertices, indices);
272
      }
273
    }
274

    
275
///////////////////////////////////////////////////////////////////////////////////////////////////
276

    
277
  public ObjectFaceShape getObjectFaceShape(int variant)
278
    {
279
    if( variant==0 )
280
      {
281
      float A = (2*SQ3/3)*SIN54;
282
      float B = 0.4f;
283
      float H = isInIconMode() ? 0.001f : 0.03f;
284
      float[][] bands     = { {H,10,0.5f,0.2f,4,0,0}, {0.001f, 1,0.5f,0.2f,3,0,0} };
285
      int[] bandIndices   = { 0,0,0,1,1,1 };
286
      float[][] corners   = { { 0.025f, 0.20f } };
287
      int[] cornerIndices = { 0,0,0,-1,-1,-1 };
288
      float[][] centers   = { {0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B} };
289
      int[] centerIndices = { 0,0,0,-1,-1,-1 };
290
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
291
      }
292
    else
293
      {
294
      final double ANGLE = 0.825f*Math.PI;
295
      final float cosA  = (float)Math.cos(ANGLE);
296
      final float sinA  = (float)Math.sin(ANGLE);
297
      float TAN54 = SIN54/COS54;
298
      float R  = 1.5f*(TAN54-(1/TAN54));
299
      float H = isInIconMode() ? 0.001f : 0.03f;
300
      float[][] bands     = { {H,15,0.5f,0.2f,6,0,0}, {0.001f, 1,0.5f,0.2f,3,0,0} };
301
      int[] bandIndices   = { 0,1,1,1,1,1 };
302
      float[][] corners   = { { 0.025f, 0.20f } };
303
      int[] cornerIndices = { 0,0,0,0,0,-1 };
304
      float[][] centers   = { { 0.0f,R*cosA,-R*sinA } };
305
      int[] centerIndices = { 0,0,0,0,0,-1 };
306
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
307
      }
308
    }
309

    
310
///////////////////////////////////////////////////////////////////////////////////////////////////
311

    
312
  public int getNumCubitVariants(int[] numLayers)
313
    {
314
    return 2;
315
    }
316

    
317
///////////////////////////////////////////////////////////////////////////////////////////////////
318

    
319
  public int getCubitVariant(int cubit, int[] numLayers)
320
    {
321
    return cubit<NUM_CORNERS ? 0:1;
322
    }
323

    
324
///////////////////////////////////////////////////////////////////////////////////////////////////
325

    
326
  public float[][] getCuts(int[] numLayers)
327
    {
328
    if( mCuts==null )
329
      {
330
      float[] cut = new float[] { 0 };
331
      mCuts = new float[][] { cut,cut,cut,cut,cut,cut };
332
      }
333

    
334
    return mCuts;
335
    }
336

    
337
///////////////////////////////////////////////////////////////////////////////////////////////////
338

    
339
  public float getStickerRadius()
340
    {
341
    return 0.15f;
342
    }
343

    
344
///////////////////////////////////////////////////////////////////////////////////////////////////
345

    
346
  public float getStickerStroke()
347
    {
348
    return isInIconMode() ? 0.20f : 0.13f;
349
    }
350

    
351
///////////////////////////////////////////////////////////////////////////////////////////////////
352

    
353
  public float[][] getStickerAngles()
354
    {
355
    return null;
356
    }
357

    
358
///////////////////////////////////////////////////////////////////////////////////////////////////
359
// PUBLIC API
360

    
361
  public String getShortName()
362
    {
363
    return ObjectType.PENT_2.name();
364
    }
365

    
366
///////////////////////////////////////////////////////////////////////////////////////////////////
367

    
368
  public long getSignature()
369
    {
370
    return ObjectType.PENT_2.ordinal();
371
    }
372

    
373
///////////////////////////////////////////////////////////////////////////////////////////////////
374

    
375
  public String getObjectName()
376
    {
377
    return "Pentultimate";
378
    }
379

    
380
///////////////////////////////////////////////////////////////////////////////////////////////////
381

    
382
  public String getInventor()
383
    {
384
    return "Jason Smith";
385
    }
386

    
387
///////////////////////////////////////////////////////////////////////////////////////////////////
388

    
389
  public int getYearOfInvention()
390
    {
391
    return 2008;
392
    }
393

    
394
///////////////////////////////////////////////////////////////////////////////////////////////////
395

    
396
  public int getComplexity()
397
    {
398
    return 3;
399
    }
400

    
401
///////////////////////////////////////////////////////////////////////////////////////////////////
402

    
403
  public String[][] getTutorials()
404
    {
405
    return new String[][]{
406
                          {"gb","raeskk-whbU","Pentultimate classification and solve","SuperAntoniovivaldi"},
407
                          {"gb","QamIeNJBB1M","How to solve a Pentultimate","bmenrigh"},
408
                         };
409
    }
410
}
(24-24/36)