Project

General

Profile

« Previous | Next » 

Revision 26d73f43

Added by Leszek Koltunski over 3 years ago

Trajber's Octahedron: progress.

View differences:

src/main/java/org/distorted/objectlib/objects/TwistyTrajber.java
40 40
public class TwistyTrajber extends ShapeOctahedron
41 41
{
42 42
  // each cut is at 1/6 of the length of the segment from the center to a vertex.
43
  public static final float CUT = 1.0f/6;
44
  private static final float LEN = 3*SQ2/2;
43
  private static final float CUT = 1.0f/6;
44
  private static final float LEN = 1.5f;
45 45

  
46 46
  // the three rotation axis of a 3x3x3 cube. Must be normalized.
47 47
  static final Static3D[] ROT_AXIS = new Static3D[]
48 48
         {
49
           new Static3D(1,0,0),
50
           new Static3D(0,1,0),
51
           new Static3D(0,0,1)
49
         new Static3D(SQ2/2, 0, SQ2/2),
50
         new Static3D(    0, 1,     0),
51
         new Static3D(SQ2/2, 0,-SQ2/2)
52 52
         };
53 53

  
54

  
55
  private static final int[] mQuatIndices = new int[] {13,12,8,9,0,1, 15,22,14,18,0,1,3,2,8,9,17,23, 0,8,9,1,15,2,3,5};
54
  private static final int[] mQuatIndices = new int[] {13,12,8,9,0,1, 15,10,14,11, 0,1,3,2, 8,9,5,4, 0,8,9,1,15,2,3,6};
56 55

  
57 56
  private int[][] mFaceColorMap, mEdgeColorMap, mCornerColorMap;
58 57
  private ScrambleState[] mStates;
......
73 72
    factory.printStickerCoords();
74 73
    }
75 74

  
76
///////////////////////////////////////////////////////////////////////////////////////////////////
77

  
78
  private int[] createState(int vertex)
79
    {
80
    int[] ret = new int[27];
81

  
82
    for(int l=0; l<3; l++)
83
      {
84
      ret[9*l  ] = l;
85
      ret[9*l+1] =-1;
86
      ret[9*l+2] = vertex;
87
      ret[9*l+3] = l;
88
      ret[9*l+4] = 1;
89
      ret[9*l+5] = vertex;
90
      ret[9*l+6] = l;
91
      ret[9*l+7] = 2;
92
      ret[9*l+8] = vertex;
93
      }
94

  
95
    return ret;
96
    }
97

  
98 75
///////////////////////////////////////////////////////////////////////////////////////////////////
99 76

  
100 77
  public ScrambleState[] getScrambleStates()
......
103 80
      {
104 81
      int[][] m = new int[16][];
105 82

  
106
      for(int i=0; i<16; i++)
107
        {
108
        m[i] = createState(i);
109
        }
83
      for(int i=0; i<16; i++) m[i] = new int[] { 0,-1,i,0,1,i,0,2,i, 1,-1,i,1,1,i,1,2,i, 2,-1,i,2,1,i,2,2,i};
110 84

  
111 85
      mStates = new ScrambleState[]
112 86
          {
......
133 107
    }
134 108

  
135 109
///////////////////////////////////////////////////////////////////////////////////////////////////
110
// quaternions are in the same order as in cuboids
111

  
112
// {13,12,8,9,0,1, 15,10,14,11,0,1,3,2,8,9,5,4, 0,8,9,1,15,2,3,6};
136 113

  
137 114
  private void initializeQuats()
138 115
    {
139 116
    mQuats = new Static4D[]
140 117
         {
141
         new Static4D(  0.0f,   0.0f,   0.0f,   1.0f),
142
         new Static4D(  1.0f,   0.0f,   0.0f,   0.0f),
143
         new Static4D(  0.0f,   1.0f,   0.0f,   0.0f),
144
         new Static4D(  0.0f,   0.0f,   1.0f,   0.0f),
145

  
146
         new Static4D( SQ2/2,  SQ2/2,  0.0f ,   0.0f),  // 4
147
         new Static4D( SQ2/2, -SQ2/2,  0.0f ,   0.0f),
148
         new Static4D( SQ2/2,   0.0f,  SQ2/2,   0.0f),
149
         new Static4D(-SQ2/2,   0.0f,  SQ2/2,   0.0f),
150
         new Static4D( SQ2/2,   0.0f,   0.0f,  SQ2/2),
151
         new Static4D( SQ2/2,   0.0f,   0.0f, -SQ2/2),
152
         new Static4D(  0.0f,  SQ2/2,  SQ2/2,   0.0f),  // 10
153
         new Static4D(  0.0f,  SQ2/2, -SQ2/2,   0.0f),
154
         new Static4D(  0.0f,  SQ2/2,   0.0f,  SQ2/2),
155
         new Static4D(  0.0f,  SQ2/2,   0.0f, -SQ2/2),
156
         new Static4D(  0.0f,   0.0f,  SQ2/2,  SQ2/2),
157
         new Static4D(  0.0f,   0.0f,  SQ2/2, -SQ2/2),
158

  
159
         new Static4D(  0.5f,   0.5f,   0.5f,   0.5f),  // 16
160
         new Static4D(  0.5f,   0.5f,  -0.5f,   0.5f),
161
         new Static4D(  0.5f,   0.5f,  -0.5f,  -0.5f),
162
         new Static4D(  0.5f,  -0.5f,   0.5f,  -0.5f),
163
         new Static4D( -0.5f,  -0.5f,  -0.5f,   0.5f),  // 20
164
         new Static4D( -0.5f,   0.5f,  -0.5f,  -0.5f),
165
         new Static4D( -0.5f,   0.5f,   0.5f,  -0.5f),
166
         new Static4D( -0.5f,   0.5f,   0.5f,   0.5f)
118
         new Static4D(  0.0f,   0.0f,   0.0f,   1.0f),  // 0  nothing                 // OK
119
         new Static4D( SQ2/2,   0.0f,  SQ2/2,   0.0f),  // 1  ( 1, 0,-1) 180          // OK
120
         new Static4D(  0.0f,   1.0f,   0.0f,   0.0f),  // 2  ( 0, 1, 0) 180          // OK
121
         new Static4D( SQ2/2,   0.0f, -SQ2/2,   0.0f),  // 3  ( 1, 0, 1) 180          // OK
122

  
123
         new Static4D(  0.5f,  SQ2/2,  -0.5f,   0.0f),  // 4 (0.5,SQ2/2,0.5) 180
124
         new Static4D(  0.5f, -SQ2/2,  -0.5f,   0.0f),  // 5 (0.5,-SQ2/2,-0.5) 180
125
         new Static4D(  1.0f,   0.0f,   0.0f,   0.0f),  // 6 (1,0,0) 180
126
         new Static4D(  0.0f,   0.0f,   1.0f,   0.0f),  // 7 (0,0,1) 180
127
         new Static4D(  0.5f,   0.0f,   0.5f,  SQ2/2),  // 8  ( 1, 0, 1) +-90         // OK
128
         new Static4D(  0.5f,   0.0f,   0.5f, -SQ2/2),  // 9  ( 1, 0, 1) -+90         // OK
129
         new Static4D(  0.5f,  SQ2/2,   0.5f,   0.0f),  // 10 (-0.5,-SQ2/2,-0.5) 180
130
         new Static4D(  0.5f, -SQ2/2,   0.5f,   0.0f),  // 11 (0.5,-SQ2/2,0.5) 180
131
         new Static4D(  0.0f,  SQ2/2,   0.0f,  SQ2/2),  // 12  ( 0, 1, 0) +-90        // OK
132
         new Static4D(  0.0f,  SQ2/2,   0.0f, -SQ2/2),  // 13  ( 0, 1, 0) -+90        // OK
133
         new Static4D(  0.5f,   0.0f,  -0.5f, -SQ2/2),  // 15  ( 1, 0,-1) -+90        // OK
134
         new Static4D(  0.5f,   0.0f,  -0.5f,  SQ2/2),  // 14  ( 1, 0,-1) +-90        // OK
135

  
136
         new Static4D( SQ2/2,   0.5f,   0.0f,   0.5f),  // 16 (+,+,0) +
137
         new Static4D(  0.0f,  -0.5f,  SQ2/2,  -0.5f),  // 17 (0,-,+) -
138
         new Static4D(  0.0f,   0.5f, -SQ2/2,  -0.5f),  // 18 (0,+,-) -
139
         new Static4D( SQ2/2,  -0.5f,   0.0f,  -0.5f),  // 19 (+,-,0) -
140
         new Static4D(-SQ2/2,  -0.5f,   0.0f,   0.5f),  // 20 (-,-,0) +
141
         new Static4D( SQ2/2,  -0.5f,   0.0f,   0.5f),  // 21 (+,-,0) +
142
         new Static4D(  0.0f,  -0.5f, -SQ2/2,   0.5f),  // 22 (0,-,-) +
143
         new Static4D(  0.0f,  -0.5f, -SQ2/2,  -0.5f),  // 23 (0,-,-) -
167 144
         };
168 145
    }
169 146

  
......
205 182
    {
206 183
    if( mCuts==null )
207 184
      {
208
      final float cut= CUT*LEN;
209
      mCuts = new float[3][2];
210

  
211
      mCuts[0][0] = -cut;
212
      mCuts[1][0] = -cut;
213
      mCuts[2][0] = -cut;
214
      mCuts[0][1] = +cut;
215
      mCuts[1][1] = +cut;
216
      mCuts[2][1] = +cut;
185
      final float cut= CUT*LEN*SQ2;
186
      mCuts = new float[][] { {-cut,+cut},{-cut,+cut},{-cut,+cut} };
217 187
      }
218 188

  
219 189
    return mCuts;
......
249 219
    return TYPE_NOT_SPLIT;
250 220
    }
251 221

  
222
///////////////////////////////////////////////////////////////////////////////////////////////////
223

  
224
  public int[][][] getEnabled()
225
    {
226
    return new int[][][]
227
      {
228
          {{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}}
229
      };
230
    }
231

  
252 232
///////////////////////////////////////////////////////////////////////////////////////////////////
253 233

  
254 234
  public float[] getDist3D(int[] numLayers)
......
271 251
      {
272 252
      mCenters = new float[][]
273 253
          {
254
              {   LEN,       0,   LEN},
255
              {  -LEN,       0,  -LEN},
256
              {     0, SQ2*LEN,     0},
257
              {     0,-SQ2*LEN,     0},
258
              {  -LEN,       0,   LEN},
259
              {   LEN,       0,  -LEN},
260

  
261
              {-LEN/2, (SQ2/2)*LEN, LEN/2},
262
              { LEN/2, (SQ2/2)*LEN,-LEN/2},
263
              {-LEN/2,-(SQ2/2)*LEN, LEN/2},
264
              { LEN/2,-(SQ2/2)*LEN,-LEN/2},
265
              {     0,     0,   LEN},
274 266
              {   LEN,     0,     0},
275 267
              {  -LEN,     0,     0},
276
              {     0,   LEN,     0},
277
              {     0,  -LEN,     0},
278
              {     0,     0,   LEN},
279 268
              {     0,     0,  -LEN},
280

  
281
              {     0, LEN/2, LEN/2},
282
              {     0, LEN/2,-LEN/2},
283
              {     0,-LEN/2, LEN/2},
284
              {     0,-LEN/2,-LEN/2},
285
              { LEN/2,     0, LEN/2},
286
              { LEN/2,     0,-LEN/2},
287
              {-LEN/2,     0, LEN/2},
288
              {-LEN/2,     0,-LEN/2},
289
              { LEN/2, LEN/2,     0},
290
              { LEN/2,-LEN/2,     0},
291
              {-LEN/2, LEN/2,     0},
292
              {-LEN/2,-LEN/2,     0},
293

  
294
              { LEN/3, LEN/3, LEN/3},
295
              { LEN/3, LEN/3,-LEN/3},
296
              { LEN/3,-LEN/3, LEN/3},
297
              { LEN/3,-LEN/3,-LEN/3},
298
              {-LEN/3, LEN/3, LEN/3},
299
              {-LEN/3, LEN/3,-LEN/3},
300
              {-LEN/3,-LEN/3, LEN/3},
301
              {-LEN/3,-LEN/3,-LEN/3},
269
              { LEN/2, (SQ2/2)*LEN, LEN/2},
270
              { LEN/2,-(SQ2/2)*LEN, LEN/2},
271
              {-LEN/2, (SQ2/2)*LEN,-LEN/2},
272
              {-LEN/2,-(SQ2/2)*LEN,-LEN/2},
273

  
274
              {       0, SQ2*LEN/3, 2*LEN/3},
275
              { 2*LEN/3, SQ2*LEN/3,       0},
276
              {       0,-SQ2*LEN/3, 2*LEN/3},
277
              { 2*LEN/3,-SQ2*LEN/3,       0},
278
              {-2*LEN/3, SQ2*LEN/3,       0},
279
              {       0, SQ2*LEN/3,-2*LEN/3},
280
              {-2*LEN/3,-SQ2*LEN/3,       0},
281
              {       0,-SQ2*LEN/3,-2*LEN/3},
302 282
          };
303 283
      }
304 284

  
305 285
    return mCenters;
306 286
    }
307 287

  
308
///////////////////////////////////////////////////////////////////////////////////////////////////
309

  
310
  public int[][][] getEnabled()
311
    {
312
    return new int[][][]
313
      {
314
          {{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}}
315
      };
316
    }
317

  
318 288
///////////////////////////////////////////////////////////////////////////////////////////////////
319 289

  
320 290
  public ObjectShape getObjectShape(int variant)
321 291
    {
322 292
    if( variant==0 )
323 293
      {
324
      final float A = CUT*LEN;
325
      final float B = A-LEN;
294
      final float A = SQ2*CUT*LEN;
295
      final float B =     CUT*LEN;
326 296

  
327 297
      float[][] vertices = new float[][]
328 298
          {
329 299
             {    0,    0,    0},
330
             {    0,    A,   -A},
331
             {    0,   -A,   -A},
332
             {    A,    0,   -A},
333
             {   -A,    0,   -A},
334
             {    A,    A, -2*A},
335
             {    A,   -A, -2*A},
336
             {   -A,    A, -2*A},
337
             {   -A,   -A, -2*A},
338
             {    A,    A,    B},
339
             {    A,   -A,    B},
340
             {   -A,    A,    B},
341
             {   -A,   -A,    B}
300
             {    B,    A,   -B},
301
             {    B,   -A,   -B},
302
             {  2*B,    0,    0},
303
             {    0,    0, -2*B},
304
             {  3*B,    A,   -B},
305
             {  3*B,   -A,   -B},
306
             {    B,    A, -3*B},
307
             {    B,   -A, -3*B},
308

  
309
             {  LEN      ,    A, SQ2*A-LEN},
310
             {  LEN      ,   -A, SQ2*A-LEN},
311
             {  LEN-SQ2*A,    A,      -LEN},
312
             {  LEN-SQ2*A,   -A,      -LEN}
342 313
          };
343 314

  
344 315
      int[][] vert_indices = new int[][]
......
354 325
             {9,10,12,11}
355 326
          };
356 327

  
357
      float[][] bands     = new float[][] { {0.05f,35,0.15f,0.3f,4,1,1},{0.00f,35,0.15f,0.3f,4,0,0} };
328
      float[][] bands     = new float[][] { {0.00f,35,0.15f,0.3f,4,1,1},{0.00f,35,0.15f,0.3f,4,0,0} };
358 329
      int[] bandIndices   = new int[] { 0,0,0,0,1,1,1,1,1 };
359 330
      float[][] corners   = new float[][] { {0.03f,0.10f} };
360 331
      int[] cornerIndices = new int[] { 0,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1 };
361
      float[][] centers   = new float[][] { {0.0f, 0.0f, -LEN/2} };
332
      float[][] centers   = new float[][] { { LEN/2, 0.0f, -LEN/2} };
362 333
      int[] centerIndices = new int[] { 0,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1 };
363 334
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
364 335
      }
365 336
    if( variant==1 )
366 337
      {
367
      final float A = CUT*LEN;
368
      final float B = A-LEN;
338
      final float A = SQ2*CUT*LEN;
339
      final float B = CUT*LEN;
340
      final float C = LEN-2*LEN*CUT;
369 341

  
370 342
      float[][] vertices = new float[][]
371 343
          {
372
             {    A-LEN/2,    0,   -A+LEN/2},
373
             {    A-LEN/2,    A, -2*A+LEN/2},
374
             {    A-LEN/2,   -A, -2*A+LEN/2},
375
             {   -B-LEN/2,    0,    B+LEN/2},
376
             { -B-A-LEN/2,    A,    B+LEN/2},
377
             { -B-A-LEN/2,   -A,    B+LEN/2},
378
             {    A-LEN/2,    A,    B+LEN/2},
379
             {    A-LEN/2,   -A,    B+LEN/2},
344
             {    -C,    0,   0},
345
             {  -C+A,    A,  -B},
346
             {  -C+A,   -A,  -B},
347
             {     C,    0,   0},
348
             {   C-A,    A,  -B},
349
             {   C-A,   -A,  -B},
350
             {     0,    A,  -C},
351
             {     0,   -A,  -C},
380 352
          };
381 353

  
382 354
      int[][] vert_indices = new int[][]
......
389 361
             {3,5,7,6,4}
390 362
          };
391 363

  
392
      float[][] bands     = new float[][] { {0.03f,35,0.15f,0.3f,3,1,1},{0.00f,35,0.15f,0.3f,3,0,0} };
364
      float[][] bands     = new float[][] { {0.00f,35,0.15f,0.3f,3,1,1},{0.00f,35,0.15f,0.3f,3,0,0} };
393 365
      int[] bandIndices   = new int[] { 0,0,1,1,1,1 };
394 366
      float[][] corners   = new float[][] { {0.02f,0.10f} };
395 367
      int[] cornerIndices = new int[] { 0,0,0,0,0,0,-1,-1 };
396
      float[][] centers   = new float[][] { {-LEN/4, 0, -LEN/4} };
368
      float[][] centers   = new float[][] { { 0, 0, -LEN/2} };
397 369
      int[] centerIndices = new int[] { 0,0,0,0,0,0,-1,-1 };
398 370
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
399 371
      }
400 372
    else
401 373
      {
402
      final float A = CUT*LEN;
403
      final float B = A-LEN;
374
      final float A = SQ2*CUT*LEN;
375
      final float C = LEN-2*LEN*CUT;
376
      final float L = C-A;
404 377

  
405 378
      float[][] vertices = new float[][]
406 379
          {
407
             {   A-LEN/3,   A-LEN/3, -2*A+2*LEN/3},
408
             {-B-A-LEN/3,   A-LEN/3,    B+2*LEN/3},
409
             {   A-LEN/3,-B-A-LEN/3,    B+2*LEN/3},
410
             {   A-LEN/3,   A-LEN/3,    B+2*LEN/3},
380
             { -L, -(SQ2/3)*L,   L/3 },
381
             {  L, -(SQ2/3)*L,   L/3 },
382
             {  0,(2*SQ2/3)*L,-2*L/3 },
383
             {  0, -(SQ2/3)*L,-2*L/3 },
411 384
          };
412 385

  
413 386
      int[][] vert_indices = new int[][]
......
418 391
             {1,3,2},
419 392
          };
420 393

  
421
      float[][] bands     = new float[][] { {0.05f,35,0.15f,0.3f,4,1,1},{0.00f,35,0.15f,0.3f,4,0,0} };
394
      float[][] bands     = new float[][] { {0.00f,35,0.15f,0.3f,4,1,1},{0.00f,35,0.15f,0.3f,4,0,0} };
422 395
      int[] bandIndices   = new int[] { 0,1,1,1 };
423 396
      float[][] corners   = new float[][] { {0.02f,0.10f} };
424 397
      int[] cornerIndices = new int[] { 0,0,0,-1 };
425
      float[][] centers   = new float[][] { {(A-LEN/3)/2 , (A-LEN/3)/2 , (B-LEN/3)/2} };
398
      float[][] centers   = new float[][] { {0, -(SQ2/3)*L,-2*L/3} };
426 399
      int[] centerIndices = new int[] { 0,0,0,-1 };
427 400
      return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
428 401
      }
......
470 443

  
471 444
    if( mEdgeColorMap==null)
472 445
      {
473
      mEdgeColorMap = new int[][] { {3,0},{2,1},{4,7},{5,6},  {0,4},{5,1},{7,3},{2,6}, {1,0},{4,5},{2,3},{7,6} };
446
      mEdgeColorMap = new int[][] { {3,0},{1,2},{4,7},{6,5},  {0,4},{5,1},{7,3},{2,6}, {1,0},{4,5},{3,2},{6,7} };
474 447
      }
475 448

  
476 449
    if( mCornerColorMap==null)
......
496 469
      {
497 470
      float[][] STICKERS = new float[][]
498 471
        {
499
          { -0.5f, -0.5f, 0.28867516f, -0.28867516f, 0.5f, 0.5f, -0.28867516f, 0.28867516f },
500
          { -0.4451682f, -0.228946f, 0.5f, 0.02431105f, 0.32702217f, 0.19728887f, -0.38185394f, 0.007346081f },
501
          { -0.36602542f, -0.36602542f, 0.5f, -0.13397461f, -0.13397461f, 0.5f }
472
          { -0.5f, -0.2886751f, 0.16666666f, -0.2886751f, 0.5f, 0.2886751f, -0.16666666f, 0.2886751f },
473
          { -0.5f, -0.10825317f, 0.5f, -0.10825317f, 0.3232233f, 0.10825317f, -0.32322332f, 0.10825317f },
474
          { -0.43301275f, -0.25f, 0.4330127f, -0.25f, 0.0f, 0.5f }
502 475
        };
503 476

  
504 477
      float R1 = 0.09f;
src/main/res/raw/compute_quats.c
2 2
#include <math.h>
3 3
#include <stdlib.h>
4 4

  
5
#define SQUARE
5
#define TRAJBER
6 6

  
7 7
#define SQ2 1.41421356237f
8 8
#define SQ3 1.73205080757f
......
77 77
                    { COS15, 0, SIN15 } };
78 78
#endif
79 79

  
80
#ifdef TRAJBER
81

  
82
int basic[] = { 4,4,4 };
83

  
84
float axis[][3] = { { SQ2/2, 0, SQ2/2 },
85
                    { SQ2/2, 0,-SQ2/2 },
86
                    {     0, 1,     0 } };
87
                     
88
#endif
89

  
80 90
int inserted=0;
81 91

  
82 92
///////////////////////////////////////////////////////////////////

Also available in: Unified diff