Project

General

Profile

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

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

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.ObjectType;
28
import org.distorted.objectlib.scrambling.ScrambleState;
29

    
30
import java.io.InputStream;
31

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

    
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38

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

    
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

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

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

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

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

    
67
    return mStates;
68
    }
69

    
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71

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

    
78
///////////////////////////////////////////////////////////////////////////////////////////////////
79

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

    
87
///////////////////////////////////////////////////////////////////////////////////////////////////
88

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

    
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110

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

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

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

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

    
136
    return mPosition;
137
    }
138

    
139
///////////////////////////////////////////////////////////////////////////////////////////////////
140

    
141
  public Static4D getCubitQuats(int cubit, int[] numLayers)
142
    {
143
    if( mQuatIndex==null )
144
      {
145
      mQuatIndex = new int[]
146
        {
147
         0,29,59,48,18,53,22,49,11,54,10,52,17,27,19,26, 9,28,23,45,
148
         0, 4, 5, 6,26, 3, 2, 7,16,13, 1,19
149
        };
150
      }
151

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

    
155
///////////////////////////////////////////////////////////////////////////////////////////////////
156

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
274
///////////////////////////////////////////////////////////////////////////////////////////////////
275

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

    
309
///////////////////////////////////////////////////////////////////////////////////////////////////
310

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

    
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317

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

    
323
///////////////////////////////////////////////////////////////////////////////////////////////////
324

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

    
333
    return mCuts;
334
    }
335

    
336
///////////////////////////////////////////////////////////////////////////////////////////////////
337

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

    
343
///////////////////////////////////////////////////////////////////////////////////////////////////
344

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

    
350
///////////////////////////////////////////////////////////////////////////////////////////////////
351

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

    
357
///////////////////////////////////////////////////////////////////////////////////////////////////
358
// PUBLIC API
359

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

    
365
///////////////////////////////////////////////////////////////////////////////////////////////////
366

    
367
  public ObjectSignature getSignature()
368
    {
369
    return new ObjectSignature(ObjectType.PENT_2);
370
    }
371

    
372
///////////////////////////////////////////////////////////////////////////////////////////////////
373

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

    
379
///////////////////////////////////////////////////////////////////////////////////////////////////
380

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

    
386
///////////////////////////////////////////////////////////////////////////////////////////////////
387

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

    
393
///////////////////////////////////////////////////////////////////////////////////////////////////
394

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

    
400
///////////////////////////////////////////////////////////////////////////////////////////////////
401

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