Project

General

Profile

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

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

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.helpers.ObjectSignature;
27
import org.distorted.objectlib.main.InitData;
28
import org.distorted.objectlib.main.ObjectType;
29
import org.distorted.objectlib.scrambling.ScrambleState;
30

    
31
import java.io.InputStream;
32

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

    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

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

    
46
///////////////////////////////////////////////////////////////////////////////////////////////////
47

    
48
  public TwistyPentultimate(InitData data, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
49
    {
50
    super(data, meshState, iconMode, quat, move, scale, stream);
51
    }
52

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

    
55
  @Override
56
  public ScrambleState[] getScrambleStates()
57
    {
58
    if( mStates==null )
59
      {
60
      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 };
61

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

    
68
    return mStates;
69
    }
70

    
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72

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

    
79
///////////////////////////////////////////////////////////////////////////////////////////////////
80

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

    
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

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

    
110
///////////////////////////////////////////////////////////////////////////////////////////////////
111

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

    
119
      mPosition = new float[NUM_CORNERS+NUM_CENTERS][3];
120

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

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

    
137
    return mPosition;
138
    }
139

    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141

    
142
  public Static4D getCubitQuats(int cubit, int[] numLayers)
143
    {
144
    if( mQuatIndex==null )
145
      {
146
      mQuatIndex = new int[]
147
        {
148
         0,29,59,48,18,53,22,49,11,54,10,52,17,27,19,26, 9,28,23,45,
149
         0, 4, 5, 6,26, 3, 2, 7,16,13, 1,19
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
             {0,1,2,3,4},
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 ObjectSignature getSignature()
369
    {
370
    return new ObjectSignature(ObjectType.PENT_2);
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
}
(28-28/40)