Project

General

Profile

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

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

1 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 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 82eb152a Leszek Koltunski
import java.io.InputStream;
23 29b82486 Leszek Koltunski
24 ecf3d6e3 Leszek Koltunski
import org.distorted.library.type.Static3D;
25 29b82486 Leszek Koltunski
import org.distorted.library.type.Static4D;
26
27 3ee1d662 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectFaceShape;
28 1d581993 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectSignature;
29 8005e762 Leszek Koltunski
import org.distorted.objectlib.main.ObjectType;
30 198c5bf0 Leszek Koltunski
import org.distorted.objectlib.helpers.ObjectShape;
31 10b7e306 Leszek Koltunski
import org.distorted.objectlib.scrambling.ScrambleState;
32 29b82486 Leszek Koltunski
33
///////////////////////////////////////////////////////////////////////////////////////////////////
34
35
public class TwistySquare2 extends TwistySquare
36
{
37
  private ScrambleState[] mStates;
38 82e62580 Leszek Koltunski
  private int[] mQuatIndex;
39 29b82486 Leszek Koltunski
  private float[][] mCenters;
40
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42
43 3bf19410 Leszek Koltunski
  public TwistySquare2(int[] numL, int meshState, int iconMode, Static4D quat, Static3D move, float scale, InputStream stream)
44 29b82486 Leszek Koltunski
    {
45 3bf19410 Leszek Koltunski
    super(numL, meshState, iconMode, quat, move, scale, stream);
46 29b82486 Leszek Koltunski
    }
47
48 1b7ece90 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
49
50 ed0988c0 Leszek Koltunski
  @Override
51 19595510 Leszek Koltunski
  public int[][] getSolvedQuats()
52 1b7ece90 Leszek Koltunski
    {
53 ed0988c0 Leszek Koltunski
    return new int[][]
54
      {
55
        { 2, 0,1 },                                   // 2 middle cubits in the first group
56
        {12, 2,4,6,8,10,12,14,16,19,21,23,25,  17 },  // 12 front and back edges and corners in the second group with quat[17]
57
        {12, 3,5,7,9,11,13,15,17,18,20,22,24,  23 }   // 12 left and right edges and corners in the third group with quat[23]
58
      };
59 1b7ece90 Leszek Koltunski
    }
60
61 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
62
63 f9a81f52 Leszek Koltunski
  public ScrambleState[] getScrambleStates()
64 29b82486 Leszek Koltunski
    {
65
    if( mStates==null )
66
      {
67
      int[] SL_6 = new int[] { 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1, 0,1,1, 1,1,1};
68
      int[] SL_1 = new int[] { 0,1,1, 1,1,1 };
69
      int[] LO_2 = new int[] { 0,-5,2, 0,-4,2, 0,-3,2, 0,-2,2, 0,-1,2, 0,1,2, 0,2,2, 0,3,2, 0,4,2, 0,5,2, 0,5,2 };
70
      int[] LO_3 = new int[] { 0,-5,3, 0,-4,3, 0,-3,3, 0,-2,3, 0,-1,3, 0,1,3, 0,2,3, 0,3,3, 0,4,3, 0,5,3, 0,5,3 };
71
      int[] LO_4 = new int[] { 0,-5,4, 0,-4,4, 0,-3,4, 0,-2,4, 0,-1,4, 0,1,4, 0,2,4, 0,3,4, 0,4,4, 0,5,4, 0,5,4 };
72
73
      mStates = new ScrambleState[]
74
        {
75
        new ScrambleState( new int[][] { LO_2, SL_6, LO_3 } ),  // 0
76
        new ScrambleState( new int[][] { LO_2, null, LO_3 } ),  // SL
77
        new ScrambleState( new int[][] { null, SL_1, LO_4 } ),  // LO
78
        new ScrambleState( new int[][] { LO_4, SL_1, null } ),  // UP
79
        new ScrambleState( new int[][] { null, SL_1, null } ),  // UL
80
        };
81
      }
82
83
    return mStates;
84
    }
85
86 d0e6cf7f Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
87
88
  public float[][] getCubitPositions(int[] numLayers)
89
    {
90
    if( mCenters ==null )
91
      {
92
      float Y = 0.75f + X/2;
93
94
      mCenters = new float[][]
95
        {
96 ed0988c0 Leszek Koltunski
         { 1.5f, 0.0f, 0.0f }, // 0
97 d0e6cf7f Leszek Koltunski
         {-1.5f, 0.0f, 0.0f },
98
99 ed0988c0 Leszek Koltunski
         { 0.0f, 1.0f, 1.5f }, // 2
100 d0e6cf7f Leszek Koltunski
         { 1.5f, 1.0f, 0.0f },
101
         { 0.0f, 1.0f,-1.5f },
102
         {-1.5f, 1.0f, 0.0f },
103
         { 0.0f,-1.0f, 1.5f },
104
         { 1.5f,-1.0f, 0.0f },
105
         { 0.0f,-1.0f,-1.5f },
106
         {-1.5f,-1.0f, 0.0f },
107
108 ed0988c0 Leszek Koltunski
         {    Y, 1.0f, 1.5f }, // 10
109 d0e6cf7f Leszek Koltunski
         { 1.5f, 1.0f,   -Y },
110
         {   -Y, 1.0f,-1.5f },
111
         {-1.5f, 1.0f,    Y },
112
         {    Y,-1.0f, 1.5f },
113
         { 1.5f,-1.0f,   -Y },
114
         {   -Y,-1.0f,-1.5f },
115
         {-1.5f,-1.0f,    Y },
116
117 ed0988c0 Leszek Koltunski
         { 1.5f, 1.0f,    Y }, // 18
118 d0e6cf7f Leszek Koltunski
         {    Y, 1.0f,-1.5f },
119
         {-1.5f, 1.0f,   -Y },
120
         {   -Y, 1.0f, 1.5f },
121
         { 1.5f,-1.0f,    Y },
122
         {    Y,-1.0f,-1.5f },
123
         {-1.5f,-1.0f,   -Y },
124
         {   -Y,-1.0f, 1.5f },
125
        };
126
      }
127
128
    return mCenters;
129
    }
130
131
///////////////////////////////////////////////////////////////////////////////////////////////////
132
133
  public Static4D getCubitQuats(int cubit, int[] numLayers)
134
    {
135 82e62580 Leszek Koltunski
    if( mQuatIndex==null )
136 d0e6cf7f Leszek Koltunski
      {
137 82e62580 Leszek Koltunski
      mQuatIndex = new int[]
138 d0e6cf7f Leszek Koltunski
        {
139
        0, 6,
140 82e62580 Leszek Koltunski
        0, 9, 6, 3,17,14,23,20,
141
        0, 9, 6, 3, 0, 9, 6, 3,14, 23, 20, 17, 14, 23, 20, 17
142 d0e6cf7f Leszek Koltunski
        };
143
      }
144
145 82e62580 Leszek Koltunski
    return mObjectQuats[mQuatIndex[cubit]];
146 d0e6cf7f Leszek Koltunski
    }
147
148 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
149
150 e30c522a Leszek Koltunski
  public ObjectShape getObjectShape(int variant)
151 29b82486 Leszek Koltunski
    {
152
    if( variant==0 )
153
      {
154 4e9f2df5 Leszek Koltunski
      float[][] vertices =
155 29b82486 Leszek Koltunski
        {
156 57ef6378 Leszek Koltunski
         { -1.5f-X, 0.5f, 1.5f },
157
         {    0.0f, 0.5f, 1.5f },
158
         {    0.0f, 0.5f,-1.5f },
159
         { -1.5f+X, 0.5f,-1.5f },
160
         { -1.5f-X,-0.5f, 1.5f },
161
         {    0.0f,-0.5f, 1.5f },
162
         {    0.0f,-0.5f,-1.5f },
163
         { -1.5f+X,-0.5f,-1.5f }
164 29b82486 Leszek Koltunski
        };
165
166 4e9f2df5 Leszek Koltunski
      int[][] indices =
167 29b82486 Leszek Koltunski
        {
168
         {4,5,1,0},
169
         {5,6,2,1},
170
         {6,7,3,2},
171 33c707e8 Leszek Koltunski
         {7,4,0,3},
172
         {0,1,2,3},
173 846b69f3 Leszek Koltunski
         {7,6,5,4}
174 29b82486 Leszek Koltunski
        };
175
176 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
177 29b82486 Leszek Koltunski
      }
178
    else if( variant==1 )
179
      {
180 4e9f2df5 Leszek Koltunski
      float[][] vertices =
181 29b82486 Leszek Koltunski
        {
182 57ef6378 Leszek Koltunski
         {  -X, 0.5f, 0.0f },
183
         {  +X, 0.5f, 0.0f },
184
         {0.0f, 0.5f,-1.5f },
185
         {  -X,-0.5f, 0.0f },
186
         {  +X,-0.5f, 0.0f },
187
         {0.0f,-0.5f,-1.5f },
188 29b82486 Leszek Koltunski
        };
189
190 4e9f2df5 Leszek Koltunski
      int[][] indices =
191 29b82486 Leszek Koltunski
        {
192
         {0,1,2},
193
         {3,4,1,0},
194 846b69f3 Leszek Koltunski
         {5,4,3},
195 29b82486 Leszek Koltunski
         {4,5,2,1},
196
         {5,3,0,2}
197
        };
198
199 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
200 29b82486 Leszek Koltunski
      }
201
    else
202
      {
203 4e9f2df5 Leszek Koltunski
      float[][] vertices =
204 29b82486 Leszek Koltunski
        {
205 57ef6378 Leszek Koltunski
         {-0.75f+X/2, 0.5f,  0.0f },
206
         { 0.75f-X/2, 0.5f,  0.0f },
207
         {-0.75f-X/2, 0.5f, -1.5f },
208
         {-0.75f+X/2,-0.5f,  0.0f },
209
         { 0.75f-X/2,-0.5f,  0.0f },
210
         {-0.75f-X/2,-0.5f, -1.5f }
211 29b82486 Leszek Koltunski
        };
212 4e9f2df5 Leszek Koltunski
      int[][] indices =
213 29b82486 Leszek Koltunski
        {
214
         {0,1,2},
215
         {3,4,1,0},
216 c187cb69 Leszek Koltunski
         {5,4,3},
217 29b82486 Leszek Koltunski
         {4,5,2,1},
218
         {5,3,0,2}
219
        };
220
221 59a971c1 Leszek Koltunski
      return new ObjectShape(vertices, indices);
222 3ee1d662 Leszek Koltunski
      }
223
    }
224
225
///////////////////////////////////////////////////////////////////////////////////////////////////
226
227
  public ObjectFaceShape getObjectFaceShape(int variant)
228
    {
229
    if( variant==0 )
230
      {
231 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.04f;
232
      float h2 = isInIconMode() ? 0.001f : 0.02f;
233
      float[][] bands     = { {h1,35,0.2f,0.8f,5,2,1}, {h2,35,0.5f,1.0f,5,2,1}, {0.001f,35,0.3f,0.8f,5,2,1} };
234 846b69f3 Leszek Koltunski
      int[] bandIndices   = { 0,0,1,2,2,2 };
235 3ee1d662 Leszek Koltunski
      float[][] corners   = { {0.03f,0.05f} };
236
      int[] cornerIndices = { 0,0,0,0,0,0,0,0 };
237
      float[][] centers   = { { -0.75f, 0.0f, 0.0f} };
238
      int[] centerIndices = { 0,0,0,0,0,0,0,0 };
239
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
240
      }
241
    else if( variant==1 )
242
      {
243 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.038f;
244
      float[][] bands     = { {h1,35,0.5f,0.9f, 5,2,1}, {0.001f,35,0.5f,0.9f, 5,2,1} };
245 846b69f3 Leszek Koltunski
      int[] bandIndices   = { 0,0,0,1,1 };
246 3ee1d662 Leszek Koltunski
      float[][] corners   = { {0.04f,0.15f} };
247
      int[] cornerIndices = { 0,0,-1,0,0,-1 };
248
      float[][] centers   = { { 0.0f, 0.0f,-0.5f} };
249
      int[] centerIndices = { 0,0,-1,0,0,-1 };
250
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
251
      }
252
    else
253
      {
254 3bf19410 Leszek Koltunski
      float h1 = isInIconMode() ? 0.001f : 0.03f;
255
      float[][] bands     = { {h1,35,0.9f,1.0f, 5,2,1}, {0.001f,35,0.9f,1.0f, 5,2,1} };
256 3ee1d662 Leszek Koltunski
      int[] bandIndices   = { 0,0,0,1,1 };
257
      float[][] corners   = { {0.05f,0.13f} };
258
      int[] cornerIndices = { 0,0,-1,0,0,-1 };
259
      float[][] centers   = { { 0.0f, 0.0f,-0.5f} };
260
      int[] centerIndices = { 0,0,-1,0,0,-1 };
261
      return new ObjectFaceShape(bands,bandIndices,corners,cornerIndices,centers,centerIndices,null);
262 29b82486 Leszek Koltunski
      }
263
    }
264
265
///////////////////////////////////////////////////////////////////////////////////////////////////
266
267 e30c522a Leszek Koltunski
  public int getNumCubitVariants(int[] numLayers)
268 29b82486 Leszek Koltunski
    {
269
    return 3;
270
    }
271
272
///////////////////////////////////////////////////////////////////////////////////////////////////
273
274 e30c522a Leszek Koltunski
  public int getCubitVariant(int cubit, int[] numLayers)
275 29b82486 Leszek Koltunski
    {
276
    return cubit<2 ? 0 : (cubit<10 ? 1:2);
277
    }
278
279 89704841 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
280
281 d53fb890 Leszek Koltunski
  public float getStickerRadius()
282 89704841 Leszek Koltunski
    {
283
    return 0.12f;
284
    }
285
286
///////////////////////////////////////////////////////////////////////////////////////////////////
287
288 d53fb890 Leszek Koltunski
  public float getStickerStroke()
289 89704841 Leszek Koltunski
    {
290 3bf19410 Leszek Koltunski
    return isInIconMode() ? 0.20f : 0.10f;
291 89704841 Leszek Koltunski
    }
292
293
///////////////////////////////////////////////////////////////////////////////////////////////////
294
295 d53fb890 Leszek Koltunski
  public float[][] getStickerAngles()
296 89704841 Leszek Koltunski
    {
297
    return null;
298
    }
299
300 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
301
// PUBLIC API
302
303 5f54927b Leszek Koltunski
  public String getShortName()
304 61aa85e4 Leszek Koltunski
    {
305 5f54927b Leszek Koltunski
    return ObjectType.SQU2_3.name();
306
    }
307
308
///////////////////////////////////////////////////////////////////////////////////////////////////
309
310 1d581993 Leszek Koltunski
  public ObjectSignature getSignature()
311 5f54927b Leszek Koltunski
    {
312 1d581993 Leszek Koltunski
    return new ObjectSignature(ObjectType.SQU2_3);
313 61aa85e4 Leszek Koltunski
    }
314
315
///////////////////////////////////////////////////////////////////////////////////////////////////
316
317 e26eb4e7 Leszek Koltunski
  public String getObjectName()
318 29b82486 Leszek Koltunski
    {
319 e26eb4e7 Leszek Koltunski
    return "Square-2";
320 29b82486 Leszek Koltunski
    }
321
322
///////////////////////////////////////////////////////////////////////////////////////////////////
323
324 e26eb4e7 Leszek Koltunski
  public String getInventor()
325 29b82486 Leszek Koltunski
    {
326 e26eb4e7 Leszek Koltunski
    return "David Litwin";
327 29b82486 Leszek Koltunski
    }
328
329 59c20632 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
330
331 e26eb4e7 Leszek Koltunski
  public int getYearOfInvention()
332 59c20632 Leszek Koltunski
    {
333
    return 1995;
334
    }
335
336 29b82486 Leszek Koltunski
///////////////////////////////////////////////////////////////////////////////////////////////////
337
338 e26eb4e7 Leszek Koltunski
  public int getComplexity()
339 29b82486 Leszek Koltunski
    {
340 b4223a92 Leszek Koltunski
    return 3;
341 29b82486 Leszek Koltunski
    }
342 052e0362 Leszek Koltunski
343
///////////////////////////////////////////////////////////////////////////////////////////////////
344
345
  public String[][] getTutorials()
346
    {
347
    return new String[][] {
348
                          {"gb","PPXojiFthEs","Square-2 Tutorial","SuperAntoniovivaldi"},
349
                          {"es","IiMwc51xKBQ","Cómo resolver Square-2","skieur cubb"},
350
                          {"ru","XZ6m8uF5oUk","Как собрать Square-2.","Илья Топор-Гилка"},
351
                          {"fr","R-m9IgYAFPA","Tutoriel: résolution du Square-2","skieur cubb"},
352
                          {"pl","SukHyoMzcgM","Square-2 TUTORIAL PL","MrUk"},
353
                          {"br","T3ts5gHLJV8","Tutorial do Square-2 1/2","Rafael Cinoto"},
354
                          {"br","4wwWE5Ni0Fw","Tutorial do Square-2 2/2","Rafael Cinoto"},
355
                          {"kr","psG9Ar4pBrc","초보자를 위한 스퀘어2 해법","SlowCuberToumai"},
356 a399e91b Leszek Koltunski
                          {"vn","_37Pc8Y_-Hs","Square-2 Tutorial","VĂN CÔNG TÙNG"},
357 052e0362 Leszek Koltunski
                         };
358
    }
359 29b82486 Leszek Koltunski
}