commit 26d73f43cffcdf6e94a668d4ecb03eb2302b0868
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Dec 20 16:49:33 2021 +0100

    Trajber's Octahedron: progress.

diff --git a/src/main/java/org/distorted/objectlib/objects/TwistyTrajber.java b/src/main/java/org/distorted/objectlib/objects/TwistyTrajber.java
index f0035fd5..67c42daa 100644
--- a/src/main/java/org/distorted/objectlib/objects/TwistyTrajber.java
+++ b/src/main/java/org/distorted/objectlib/objects/TwistyTrajber.java
@@ -40,19 +40,18 @@ import static org.distorted.objectlib.touchcontrol.TouchControl.TYPE_NOT_SPLIT;
 public class TwistyTrajber extends ShapeOctahedron
 {
   // each cut is at 1/6 of the length of the segment from the center to a vertex.
-  public static final float CUT = 1.0f/6;
-  private static final float LEN = 3*SQ2/2;
+  private static final float CUT = 1.0f/6;
+  private static final float LEN = 1.5f;
 
   // the three rotation axis of a 3x3x3 cube. Must be normalized.
   static final Static3D[] ROT_AXIS = new Static3D[]
          {
-           new Static3D(1,0,0),
-           new Static3D(0,1,0),
-           new Static3D(0,0,1)
+         new Static3D(SQ2/2, 0, SQ2/2),
+         new Static3D(    0, 1,     0),
+         new Static3D(SQ2/2, 0,-SQ2/2)
          };
 
-
-  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};
+  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};
 
   private int[][] mFaceColorMap, mEdgeColorMap, mCornerColorMap;
   private ScrambleState[] mStates;
@@ -73,28 +72,6 @@ public class TwistyTrajber extends ShapeOctahedron
     factory.printStickerCoords();
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int[] createState(int vertex)
-    {
-    int[] ret = new int[27];
-
-    for(int l=0; l<3; l++)
-      {
-      ret[9*l  ] = l;
-      ret[9*l+1] =-1;
-      ret[9*l+2] = vertex;
-      ret[9*l+3] = l;
-      ret[9*l+4] = 1;
-      ret[9*l+5] = vertex;
-      ret[9*l+6] = l;
-      ret[9*l+7] = 2;
-      ret[9*l+8] = vertex;
-      }
-
-    return ret;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public ScrambleState[] getScrambleStates()
@@ -103,10 +80,7 @@ public class TwistyTrajber extends ShapeOctahedron
       {
       int[][] m = new int[16][];
 
-      for(int i=0; i<16; i++)
-        {
-        m[i] = createState(i);
-        }
+      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};
 
       mStates = new ScrambleState[]
           {
@@ -133,37 +107,40 @@ public class TwistyTrajber extends ShapeOctahedron
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// quaternions are in the same order as in cuboids
+
+// {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};
 
   private void initializeQuats()
     {
     mQuats = new Static4D[]
          {
-         new Static4D(  0.0f,   0.0f,   0.0f,   1.0f),
-         new Static4D(  1.0f,   0.0f,   0.0f,   0.0f),
-         new Static4D(  0.0f,   1.0f,   0.0f,   0.0f),
-         new Static4D(  0.0f,   0.0f,   1.0f,   0.0f),
-
-         new Static4D( SQ2/2,  SQ2/2,  0.0f ,   0.0f),  // 4
-         new Static4D( SQ2/2, -SQ2/2,  0.0f ,   0.0f),
-         new Static4D( SQ2/2,   0.0f,  SQ2/2,   0.0f),
-         new Static4D(-SQ2/2,   0.0f,  SQ2/2,   0.0f),
-         new Static4D( SQ2/2,   0.0f,   0.0f,  SQ2/2),
-         new Static4D( SQ2/2,   0.0f,   0.0f, -SQ2/2),
-         new Static4D(  0.0f,  SQ2/2,  SQ2/2,   0.0f),  // 10
-         new Static4D(  0.0f,  SQ2/2, -SQ2/2,   0.0f),
-         new Static4D(  0.0f,  SQ2/2,   0.0f,  SQ2/2),
-         new Static4D(  0.0f,  SQ2/2,   0.0f, -SQ2/2),
-         new Static4D(  0.0f,   0.0f,  SQ2/2,  SQ2/2),
-         new Static4D(  0.0f,   0.0f,  SQ2/2, -SQ2/2),
-
-         new Static4D(  0.5f,   0.5f,   0.5f,   0.5f),  // 16
-         new Static4D(  0.5f,   0.5f,  -0.5f,   0.5f),
-         new Static4D(  0.5f,   0.5f,  -0.5f,  -0.5f),
-         new Static4D(  0.5f,  -0.5f,   0.5f,  -0.5f),
-         new Static4D( -0.5f,  -0.5f,  -0.5f,   0.5f),  // 20
-         new Static4D( -0.5f,   0.5f,  -0.5f,  -0.5f),
-         new Static4D( -0.5f,   0.5f,   0.5f,  -0.5f),
-         new Static4D( -0.5f,   0.5f,   0.5f,   0.5f)
+         new Static4D(  0.0f,   0.0f,   0.0f,   1.0f),  // 0  nothing                 // OK
+         new Static4D( SQ2/2,   0.0f,  SQ2/2,   0.0f),  // 1  ( 1, 0,-1) 180          // OK
+         new Static4D(  0.0f,   1.0f,   0.0f,   0.0f),  // 2  ( 0, 1, 0) 180          // OK
+         new Static4D( SQ2/2,   0.0f, -SQ2/2,   0.0f),  // 3  ( 1, 0, 1) 180          // OK
+
+         new Static4D(  0.5f,  SQ2/2,  -0.5f,   0.0f),  // 4 (0.5,SQ2/2,0.5) 180
+         new Static4D(  0.5f, -SQ2/2,  -0.5f,   0.0f),  // 5 (0.5,-SQ2/2,-0.5) 180
+         new Static4D(  1.0f,   0.0f,   0.0f,   0.0f),  // 6 (1,0,0) 180
+         new Static4D(  0.0f,   0.0f,   1.0f,   0.0f),  // 7 (0,0,1) 180
+         new Static4D(  0.5f,   0.0f,   0.5f,  SQ2/2),  // 8  ( 1, 0, 1) +-90         // OK
+         new Static4D(  0.5f,   0.0f,   0.5f, -SQ2/2),  // 9  ( 1, 0, 1) -+90         // OK
+         new Static4D(  0.5f,  SQ2/2,   0.5f,   0.0f),  // 10 (-0.5,-SQ2/2,-0.5) 180
+         new Static4D(  0.5f, -SQ2/2,   0.5f,   0.0f),  // 11 (0.5,-SQ2/2,0.5) 180
+         new Static4D(  0.0f,  SQ2/2,   0.0f,  SQ2/2),  // 12  ( 0, 1, 0) +-90        // OK
+         new Static4D(  0.0f,  SQ2/2,   0.0f, -SQ2/2),  // 13  ( 0, 1, 0) -+90        // OK
+         new Static4D(  0.5f,   0.0f,  -0.5f, -SQ2/2),  // 15  ( 1, 0,-1) -+90        // OK
+         new Static4D(  0.5f,   0.0f,  -0.5f,  SQ2/2),  // 14  ( 1, 0,-1) +-90        // OK
+
+         new Static4D( SQ2/2,   0.5f,   0.0f,   0.5f),  // 16 (+,+,0) +
+         new Static4D(  0.0f,  -0.5f,  SQ2/2,  -0.5f),  // 17 (0,-,+) -
+         new Static4D(  0.0f,   0.5f, -SQ2/2,  -0.5f),  // 18 (0,+,-) -
+         new Static4D( SQ2/2,  -0.5f,   0.0f,  -0.5f),  // 19 (+,-,0) -
+         new Static4D(-SQ2/2,  -0.5f,   0.0f,   0.5f),  // 20 (-,-,0) +
+         new Static4D( SQ2/2,  -0.5f,   0.0f,   0.5f),  // 21 (+,-,0) +
+         new Static4D(  0.0f,  -0.5f, -SQ2/2,   0.5f),  // 22 (0,-,-) +
+         new Static4D(  0.0f,  -0.5f, -SQ2/2,  -0.5f),  // 23 (0,-,-) -
          };
     }
 
@@ -205,15 +182,8 @@ public class TwistyTrajber extends ShapeOctahedron
     {
     if( mCuts==null )
       {
-      final float cut= CUT*LEN;
-      mCuts = new float[3][2];
-
-      mCuts[0][0] = -cut;
-      mCuts[1][0] = -cut;
-      mCuts[2][0] = -cut;
-      mCuts[0][1] = +cut;
-      mCuts[1][1] = +cut;
-      mCuts[2][1] = +cut;
+      final float cut= CUT*LEN*SQ2;
+      mCuts = new float[][] { {-cut,+cut},{-cut,+cut},{-cut,+cut} };
       }
 
     return mCuts;
@@ -249,6 +219,16 @@ public class TwistyTrajber extends ShapeOctahedron
     return TYPE_NOT_SPLIT;
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public int[][][] getEnabled()
+    {
+    return new int[][][]
+      {
+          {{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}}
+      };
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public float[] getDist3D(int[] numLayers)
@@ -271,74 +251,65 @@ public class TwistyTrajber extends ShapeOctahedron
       {
       mCenters = new float[][]
           {
+              {   LEN,       0,   LEN},
+              {  -LEN,       0,  -LEN},
+              {     0, SQ2*LEN,     0},
+              {     0,-SQ2*LEN,     0},
+              {  -LEN,       0,   LEN},
+              {   LEN,       0,  -LEN},
+
+              {-LEN/2, (SQ2/2)*LEN, LEN/2},
+              { LEN/2, (SQ2/2)*LEN,-LEN/2},
+              {-LEN/2,-(SQ2/2)*LEN, LEN/2},
+              { LEN/2,-(SQ2/2)*LEN,-LEN/2},
+              {     0,     0,   LEN},
               {   LEN,     0,     0},
               {  -LEN,     0,     0},
-              {     0,   LEN,     0},
-              {     0,  -LEN,     0},
-              {     0,     0,   LEN},
               {     0,     0,  -LEN},
-
-              {     0, LEN/2, LEN/2},
-              {     0, LEN/2,-LEN/2},
-              {     0,-LEN/2, LEN/2},
-              {     0,-LEN/2,-LEN/2},
-              { LEN/2,     0, LEN/2},
-              { LEN/2,     0,-LEN/2},
-              {-LEN/2,     0, LEN/2},
-              {-LEN/2,     0,-LEN/2},
-              { LEN/2, LEN/2,     0},
-              { LEN/2,-LEN/2,     0},
-              {-LEN/2, LEN/2,     0},
-              {-LEN/2,-LEN/2,     0},
-
-              { LEN/3, LEN/3, LEN/3},
-              { LEN/3, LEN/3,-LEN/3},
-              { LEN/3,-LEN/3, LEN/3},
-              { LEN/3,-LEN/3,-LEN/3},
-              {-LEN/3, LEN/3, LEN/3},
-              {-LEN/3, LEN/3,-LEN/3},
-              {-LEN/3,-LEN/3, LEN/3},
-              {-LEN/3,-LEN/3,-LEN/3},
+              { LEN/2, (SQ2/2)*LEN, LEN/2},
+              { LEN/2,-(SQ2/2)*LEN, LEN/2},
+              {-LEN/2, (SQ2/2)*LEN,-LEN/2},
+              {-LEN/2,-(SQ2/2)*LEN,-LEN/2},
+
+              {       0, SQ2*LEN/3, 2*LEN/3},
+              { 2*LEN/3, SQ2*LEN/3,       0},
+              {       0,-SQ2*LEN/3, 2*LEN/3},
+              { 2*LEN/3,-SQ2*LEN/3,       0},
+              {-2*LEN/3, SQ2*LEN/3,       0},
+              {       0, SQ2*LEN/3,-2*LEN/3},
+              {-2*LEN/3,-SQ2*LEN/3,       0},
+              {       0,-SQ2*LEN/3,-2*LEN/3},
           };
       }
 
     return mCenters;
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public int[][][] getEnabled()
-    {
-    return new int[][][]
-      {
-          {{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}},{{0,1,2}}
-      };
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public ObjectShape getObjectShape(int variant)
     {
     if( variant==0 )
       {
-      final float A = CUT*LEN;
-      final float B = A-LEN;
+      final float A = SQ2*CUT*LEN;
+      final float B =     CUT*LEN;
 
       float[][] vertices = new float[][]
           {
              {    0,    0,    0},
-             {    0,    A,   -A},
-             {    0,   -A,   -A},
-             {    A,    0,   -A},
-             {   -A,    0,   -A},
-             {    A,    A, -2*A},
-             {    A,   -A, -2*A},
-             {   -A,    A, -2*A},
-             {   -A,   -A, -2*A},
-             {    A,    A,    B},
-             {    A,   -A,    B},
-             {   -A,    A,    B},
-             {   -A,   -A,    B}
+             {    B,    A,   -B},
+             {    B,   -A,   -B},
+             {  2*B,    0,    0},
+             {    0,    0, -2*B},
+             {  3*B,    A,   -B},
+             {  3*B,   -A,   -B},
+             {    B,    A, -3*B},
+             {    B,   -A, -3*B},
+
+             {  LEN      ,    A, SQ2*A-LEN},
+             {  LEN      ,   -A, SQ2*A-LEN},
+             {  LEN-SQ2*A,    A,      -LEN},
+             {  LEN-SQ2*A,   -A,      -LEN}
           };
 
       int[][] vert_indices = new int[][]
@@ -354,29 +325,30 @@ public class TwistyTrajber extends ShapeOctahedron
              {9,10,12,11}
           };
 
-      float[][] bands     = new float[][] { {0.05f,35,0.15f,0.3f,4,1,1},{0.00f,35,0.15f,0.3f,4,0,0} };
+      float[][] bands     = new float[][] { {0.00f,35,0.15f,0.3f,4,1,1},{0.00f,35,0.15f,0.3f,4,0,0} };
       int[] bandIndices   = new int[] { 0,0,0,0,1,1,1,1,1 };
       float[][] corners   = new float[][] { {0.03f,0.10f} };
       int[] cornerIndices = new int[] { 0,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1 };
-      float[][] centers   = new float[][] { {0.0f, 0.0f, -LEN/2} };
+      float[][] centers   = new float[][] { { LEN/2, 0.0f, -LEN/2} };
       int[] centerIndices = new int[] { 0,-1,-1,-1,-1,0,0,0,0,-1,-1,-1,-1 };
       return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
       }
     if( variant==1 )
       {
-      final float A = CUT*LEN;
-      final float B = A-LEN;
+      final float A = SQ2*CUT*LEN;
+      final float B = CUT*LEN;
+      final float C = LEN-2*LEN*CUT;
 
       float[][] vertices = new float[][]
           {
-             {    A-LEN/2,    0,   -A+LEN/2},
-             {    A-LEN/2,    A, -2*A+LEN/2},
-             {    A-LEN/2,   -A, -2*A+LEN/2},
-             {   -B-LEN/2,    0,    B+LEN/2},
-             { -B-A-LEN/2,    A,    B+LEN/2},
-             { -B-A-LEN/2,   -A,    B+LEN/2},
-             {    A-LEN/2,    A,    B+LEN/2},
-             {    A-LEN/2,   -A,    B+LEN/2},
+             {    -C,    0,   0},
+             {  -C+A,    A,  -B},
+             {  -C+A,   -A,  -B},
+             {     C,    0,   0},
+             {   C-A,    A,  -B},
+             {   C-A,   -A,  -B},
+             {     0,    A,  -C},
+             {     0,   -A,  -C},
           };
 
       int[][] vert_indices = new int[][]
@@ -389,25 +361,26 @@ public class TwistyTrajber extends ShapeOctahedron
              {3,5,7,6,4}
           };
 
-      float[][] bands     = new float[][] { {0.03f,35,0.15f,0.3f,3,1,1},{0.00f,35,0.15f,0.3f,3,0,0} };
+      float[][] bands     = new float[][] { {0.00f,35,0.15f,0.3f,3,1,1},{0.00f,35,0.15f,0.3f,3,0,0} };
       int[] bandIndices   = new int[] { 0,0,1,1,1,1 };
       float[][] corners   = new float[][] { {0.02f,0.10f} };
       int[] cornerIndices = new int[] { 0,0,0,0,0,0,-1,-1 };
-      float[][] centers   = new float[][] { {-LEN/4, 0, -LEN/4} };
+      float[][] centers   = new float[][] { { 0, 0, -LEN/2} };
       int[] centerIndices = new int[] { 0,0,0,0,0,0,-1,-1 };
       return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
       }
     else
       {
-      final float A = CUT*LEN;
-      final float B = A-LEN;
+      final float A = SQ2*CUT*LEN;
+      final float C = LEN-2*LEN*CUT;
+      final float L = C-A;
 
       float[][] vertices = new float[][]
           {
-             {   A-LEN/3,   A-LEN/3, -2*A+2*LEN/3},
-             {-B-A-LEN/3,   A-LEN/3,    B+2*LEN/3},
-             {   A-LEN/3,-B-A-LEN/3,    B+2*LEN/3},
-             {   A-LEN/3,   A-LEN/3,    B+2*LEN/3},
+             { -L, -(SQ2/3)*L,   L/3 },
+             {  L, -(SQ2/3)*L,   L/3 },
+             {  0,(2*SQ2/3)*L,-2*L/3 },
+             {  0, -(SQ2/3)*L,-2*L/3 },
           };
 
       int[][] vert_indices = new int[][]
@@ -418,11 +391,11 @@ public class TwistyTrajber extends ShapeOctahedron
              {1,3,2},
           };
 
-      float[][] bands     = new float[][] { {0.05f,35,0.15f,0.3f,4,1,1},{0.00f,35,0.15f,0.3f,4,0,0} };
+      float[][] bands     = new float[][] { {0.00f,35,0.15f,0.3f,4,1,1},{0.00f,35,0.15f,0.3f,4,0,0} };
       int[] bandIndices   = new int[] { 0,1,1,1 };
       float[][] corners   = new float[][] { {0.02f,0.10f} };
       int[] cornerIndices = new int[] { 0,0,0,-1 };
-      float[][] centers   = new float[][] { {(A-LEN/3)/2 , (A-LEN/3)/2 , (B-LEN/3)/2} };
+      float[][] centers   = new float[][] { {0, -(SQ2/3)*L,-2*L/3} };
       int[] centerIndices = new int[] { 0,0,0,-1 };
       return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null);
       }
@@ -470,7 +443,7 @@ public class TwistyTrajber extends ShapeOctahedron
 
     if( mEdgeColorMap==null)
       {
-      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} };
+      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} };
       }
 
     if( mCornerColorMap==null)
@@ -496,9 +469,9 @@ public class TwistyTrajber extends ShapeOctahedron
       {
       float[][] STICKERS = new float[][]
         {
-          { -0.5f, -0.5f, 0.28867516f, -0.28867516f, 0.5f, 0.5f, -0.28867516f, 0.28867516f },
-          { -0.4451682f, -0.228946f, 0.5f, 0.02431105f, 0.32702217f, 0.19728887f, -0.38185394f, 0.007346081f },
-          { -0.36602542f, -0.36602542f, 0.5f, -0.13397461f, -0.13397461f, 0.5f }
+          { -0.5f, -0.2886751f, 0.16666666f, -0.2886751f, 0.5f, 0.2886751f, -0.16666666f, 0.2886751f },
+          { -0.5f, -0.10825317f, 0.5f, -0.10825317f, 0.3232233f, 0.10825317f, -0.32322332f, 0.10825317f },
+          { -0.43301275f, -0.25f, 0.4330127f, -0.25f, 0.0f, 0.5f }
         };
 
       float R1 = 0.09f;
diff --git a/src/main/res/raw/compute_quats.c b/src/main/res/raw/compute_quats.c
index 1f590acc..0dfcf860 100644
--- a/src/main/res/raw/compute_quats.c
+++ b/src/main/res/raw/compute_quats.c
@@ -2,7 +2,7 @@
 #include <math.h>
 #include <stdlib.h>
 
-#define SQUARE
+#define TRAJBER
 
 #define SQ2 1.41421356237f
 #define SQ3 1.73205080757f
@@ -77,6 +77,16 @@ float axis[][3] = { {     0, 1,     0 } ,
                     { COS15, 0, SIN15 } };
 #endif
 
+#ifdef TRAJBER
+
+int basic[] = { 4,4,4 };
+
+float axis[][3] = { { SQ2/2, 0, SQ2/2 },
+                    { SQ2/2, 0,-SQ2/2 },
+                    {     0, 1,     0 } };
+                     
+#endif
+
 int inserted=0;
 
 ///////////////////////////////////////////////////////////////////
