commit 82e6258002a992c9882856c82d21b2741f919ca5
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Apr 19 23:55:58 2022 +0200

    Progress with cubit quaternions.

diff --git a/src/main/java/org/distorted/objectlib/objects/TwistyHelicopter.java b/src/main/java/org/distorted/objectlib/objects/TwistyHelicopter.java
index ecc1bb03..50dba3fd 100644
--- a/src/main/java/org/distorted/objectlib/objects/TwistyHelicopter.java
+++ b/src/main/java/org/distorted/objectlib/objects/TwistyHelicopter.java
@@ -212,7 +212,8 @@ public class TwistyHelicopter extends ShapeHexahedron
 
   public Static4D getCubitQuats(int cubit, int[] numLayers)
     {
-    if( mQuatIndices==null ) mQuatIndices = new int[] { 0,19,21,7,18,16,17,3,12,4,19,8,3,9,13,18,11,2,22,10,1,15,14,23,17,20,21,0,5,16,7,6 };
+    if( mQuatIndices==null ) mQuatIndices = new int[] {  0,19,21, 7,18,16,17, 3,
+                                                        12, 4,19, 8, 3, 9,13,18,11,2,22,10,1,15,14,23,17,20,21,0,5,16,7,6 };
     return mObjectQuats[mQuatIndices[cubit]];
     }
 
diff --git a/src/main/java/org/distorted/objectlib/objects/TwistyMorphix.java b/src/main/java/org/distorted/objectlib/objects/TwistyMorphix.java
index 3fb806d3..c38ff0bd 100644
--- a/src/main/java/org/distorted/objectlib/objects/TwistyMorphix.java
+++ b/src/main/java/org/distorted/objectlib/objects/TwistyMorphix.java
@@ -160,8 +160,7 @@ public class TwistyMorphix extends ShapeTetrahedron
 
   public Static4D getCubitQuats(int cubit, int[] numLayers)
     {
-    int I=5; int J=2; int K=8;
-    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,I,J,K,0,I,J,K };
+    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,5,2,8,0,5,2,8 };
     return mObjectQuats[mQuatIndex[cubit]];
     }
 
diff --git a/src/main/java/org/distorted/objectlib/objects/TwistyPentultimate.java b/src/main/java/org/distorted/objectlib/objects/TwistyPentultimate.java
index 460873a4..b2bbcccc 100644
--- a/src/main/java/org/distorted/objectlib/objects/TwistyPentultimate.java
+++ b/src/main/java/org/distorted/objectlib/objects/TwistyPentultimate.java
@@ -145,7 +145,6 @@ public class TwistyPentultimate extends TwistyMinx
         {
          0, 29, 59, 48, 18, 53, 22, 49, 11, 54,
         10, 52, 17, 27, 19, 26,  9, 28, 23, 45,
-
          0, 59, 15,  6,  4,  3, 29, 10, 35,  8,  2,  5
         };
       }
diff --git a/src/main/java/org/distorted/objectlib/objects/TwistySkewb.java b/src/main/java/org/distorted/objectlib/objects/TwistySkewb.java
index 0aa44973..d1bd04fc 100644
--- a/src/main/java/org/distorted/objectlib/objects/TwistySkewb.java
+++ b/src/main/java/org/distorted/objectlib/objects/TwistySkewb.java
@@ -49,6 +49,7 @@ public class TwistySkewb extends ShapeHexahedron
   private ScrambleState[] mStates;
   private int[] mBasicAngle;
   private float[][] mCuts;
+  private float[][] mPositions;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -166,36 +167,37 @@ public class TwistySkewb extends ShapeHexahedron
 
   public float[][] getCubitPositions(int[] numLayers)
     {
-    int numL = numLayers[0];
-    final float DIST_CORNER = numL-1;
-    final float DIST_EDGE   = numL-1;
-    final float DIST_CENTER = numL-1;
-
-    final int numCorners = getNumCorners();
-    final int numEdges   = getNumEdges(numL);
-    final int numCenters = 6*getNumCentersPerFace(numL);
+    if( mPositions==null )
+      {
+      int numL = numLayers[0];
+      final float DIST_CORNER = numL-1;
+      final float DIST_EDGE   = numL-1;
+      final float DIST_CENTER = numL-1;
 
-    final float[][] CENTERS = new float[numCorners+numEdges+numCenters][];
+      final int numCorners = getNumCorners();
+      final int numEdges   = getNumEdges(numL);
+      final int numCenters = 6*getNumCentersPerFace(numL);
 
-    /// CORNERS //////////////////////////////////////////////
+      mPositions = new float[numCorners+numEdges+numCenters][];
 
-    CENTERS[0] = new float[] { DIST_CORNER, DIST_CORNER, DIST_CORNER };
-    CENTERS[1] = new float[] { DIST_CORNER, DIST_CORNER,-DIST_CORNER };
-    CENTERS[2] = new float[] { DIST_CORNER,-DIST_CORNER, DIST_CORNER };
-    CENTERS[3] = new float[] { DIST_CORNER,-DIST_CORNER,-DIST_CORNER };
-    CENTERS[4] = new float[] {-DIST_CORNER, DIST_CORNER, DIST_CORNER };
-    CENTERS[5] = new float[] {-DIST_CORNER, DIST_CORNER,-DIST_CORNER };
-    CENTERS[6] = new float[] {-DIST_CORNER,-DIST_CORNER, DIST_CORNER };
-    CENTERS[7] = new float[] {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER };
+      /// CORNERS //////////////////////////////////////////////
 
-    /// CENTERS //////////////////////////////////////////////
+      mPositions[0] = new float[] { DIST_CORNER, DIST_CORNER, DIST_CORNER };
+      mPositions[1] = new float[] { DIST_CORNER, DIST_CORNER,-DIST_CORNER };
+      mPositions[2] = new float[] { DIST_CORNER,-DIST_CORNER, DIST_CORNER };
+      mPositions[3] = new float[] { DIST_CORNER,-DIST_CORNER,-DIST_CORNER };
+      mPositions[4] = new float[] {-DIST_CORNER, DIST_CORNER, DIST_CORNER };
+      mPositions[5] = new float[] {-DIST_CORNER, DIST_CORNER,-DIST_CORNER };
+      mPositions[6] = new float[] {-DIST_CORNER,-DIST_CORNER, DIST_CORNER };
+      mPositions[7] = new float[] {-DIST_CORNER,-DIST_CORNER,-DIST_CORNER };
 
-    int index=8;
+      /// CENTERS //////////////////////////////////////////////
 
-    final float X= -1000.0f;
-    final float Y= -1001.0f;
+      int index=8;
+      final float X= -1000.0f;
+      final float Y= -1001.0f;
 
-    final float[][]  centerTable =
+      final float[][]  centerTable =
         {
             {+DIST_CENTER,X,Y},
             {-DIST_CENTER,X,Y},
@@ -205,62 +207,62 @@ public class TwistySkewb extends ShapeHexahedron
             {X,Y,-DIST_CENTER}
         };
 
-    float x,y, cen0, cen1, cen2;
+      float x,y, cen0, cen1, cen2;
 
-    for( float[] centers : centerTable )
-      {
-      x = 2-numL;
-
-      for(int i=0; i<numL-1; i++, x+=2)
+      for( float[] centers : centerTable )
         {
-        y = 2-numL;
+        x = 2-numL;
 
-        for(int j=0; j<numL-1; j++, y+=2, index++)
+        for(int i=0; i<numL-1; i++, x+=2)
           {
-               if( centers[0]==Y ) cen0 = y;
-          else if( centers[0]==X ) cen0 = x;
-          else                     cen0 = centers[0];
+          y = 2-numL;
+
+          for(int j=0; j<numL-1; j++, y+=2, index++)
+            {
+                 if( centers[0]==Y ) cen0 = y;
+            else if( centers[0]==X ) cen0 = x;
+            else                     cen0 = centers[0];
 
-               if( centers[1]==Y ) cen1 = y;
-          else if( centers[1]==X ) cen1 = x;
-          else                     cen1 = centers[1];
+                 if( centers[1]==Y ) cen1 = y;
+            else if( centers[1]==X ) cen1 = x;
+            else                     cen1 = centers[1];
 
-               if( centers[2]==Y ) cen2 = y;
-          else if( centers[2]==X ) cen2 = x;
-          else                     cen2 = centers[2];
+                 if( centers[2]==Y ) cen2 = y;
+            else if( centers[2]==X ) cen2 = x;
+            else                     cen2 = centers[2];
 
-          CENTERS[index] = new float[] {cen0,cen1,cen2};
+            mPositions[index] = new float[] {cen0,cen1,cen2};
+            }
           }
-        }
 
-      x = 3-numL;
+        x = 3-numL;
 
-      for(int i=0; i<numL-2; i++, x+=2)
-        {
-        y = 3-numL;
-
-        for(int j=0; j<numL-2; j++, y+=2, index++)
+        for(int i=0; i<numL-2; i++, x+=2)
           {
-               if( centers[0]==Y ) cen0 = y;
-          else if( centers[0]==X ) cen0 = x;
-          else                     cen0 = centers[0];
+          y = 3-numL;
+
+          for(int j=0; j<numL-2; j++, y+=2, index++)
+            {
+                 if( centers[0]==Y ) cen0 = y;
+            else if( centers[0]==X ) cen0 = x;
+            else                     cen0 = centers[0];
 
-               if( centers[1]==Y ) cen1 = y;
-          else if( centers[1]==X ) cen1 = x;
-          else                     cen1 = centers[1];
+                 if( centers[1]==Y ) cen1 = y;
+            else if( centers[1]==X ) cen1 = x;
+            else                     cen1 = centers[1];
 
-               if( centers[2]==Y ) cen2 = y;
-          else if( centers[2]==X ) cen2 = x;
-          else                     cen2 = centers[2];
+                 if( centers[2]==Y ) cen2 = y;
+            else if( centers[2]==X ) cen2 = x;
+            else                     cen2 = centers[2];
 
-          CENTERS[index] = new float[] {cen0,cen1,cen2};
+            mPositions[index] = new float[] {cen0,cen1,cen2};
+            }
           }
         }
-      }
 
-    /// EDGES ///////////////////////////////////////////////
+      /// EDGES ///////////////////////////////////////////////
 
-    final float[][]  edgeTable =
+      final float[][]  edgeTable =
         {
             {0,+DIST_EDGE,+DIST_EDGE},
             {+DIST_EDGE,0,+DIST_EDGE},
@@ -276,19 +278,20 @@ public class TwistySkewb extends ShapeHexahedron
             {-DIST_EDGE,0,-DIST_EDGE}
         };
 
-    for (float[] edges : edgeTable)
-      {
-      float c = 3-numL;
-
-      for (int j=0; j<numL-2; j++, c+=2, index++)
+      for (float[] edges : edgeTable)
         {
-        CENTERS[index] = new float[] { edges[0]==0 ? c : edges[0] ,
-                                       edges[1]==0 ? c : edges[1] ,
-                                       edges[2]==0 ? c : edges[2] };
+        float c = 3-numL;
+
+        for (int j=0; j<numL-2; j++, c+=2, index++)
+          {
+          mPositions[index] = new float[] { edges[0]==0 ? c : edges[0] ,
+                                            edges[1]==0 ? c : edges[1] ,
+                                            edges[2]==0 ? c : edges[2] };
+          }
         }
       }
 
-    return CENTERS;
+    return mPositions;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -310,7 +313,7 @@ public class TwistySkewb extends ShapeHexahedron
         case  3: return mObjectQuats[9];                   // 180 along X
         case  4: return new Static4D(0, SQ2/2,0,SQ2/2);    //  90 along Y
         case  5: return mObjectQuats[11];                  // 180 along Y
-        case  6: return mObjectQuats[10];                   // 180 along Z
+        case  6: return mObjectQuats[10];                  // 180 along Z
         case  7: return new Static4D(SQ2/2,0,-SQ2/2,0);    // 180 along (SQ2/2,0,-SQ2/2)
         }
       }
diff --git a/src/main/java/org/distorted/objectlib/objects/TwistySquare1.java b/src/main/java/org/distorted/objectlib/objects/TwistySquare1.java
index 66ba2ae0..6118782c 100644
--- a/src/main/java/org/distorted/objectlib/objects/TwistySquare1.java
+++ b/src/main/java/org/distorted/objectlib/objects/TwistySquare1.java
@@ -33,7 +33,7 @@ import org.distorted.objectlib.scrambling.ScrambleState;
 
 public class TwistySquare1 extends TwistySquare
 {
-  private int[] mQuatNumber;
+  private int[] mQuatIndex;
   private float[][] mCenters;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -96,9 +96,9 @@ public class TwistySquare1 extends TwistySquare
 
   public Static4D getCubitQuats(int cubit, int[] numLayers)
     {
-    if( mQuatNumber ==null )
+    if( mQuatIndex ==null )
       {
-      mQuatNumber = new int[]
+      mQuatIndex = new int[]
         {
         0, 6,
         0, 9, 6, 3, 17, 14, 23, 20,
@@ -106,7 +106,7 @@ public class TwistySquare1 extends TwistySquare
         };
       }
 
-    return mObjectQuats[mQuatNumber[cubit]];
+    return mObjectQuats[mQuatIndex[cubit]];
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/objectlib/objects/TwistySquare2.java b/src/main/java/org/distorted/objectlib/objects/TwistySquare2.java
index 279e0645..7d2cbd2c 100644
--- a/src/main/java/org/distorted/objectlib/objects/TwistySquare2.java
+++ b/src/main/java/org/distorted/objectlib/objects/TwistySquare2.java
@@ -34,7 +34,7 @@ import org.distorted.objectlib.scrambling.ScrambleState;
 public class TwistySquare2 extends TwistySquare
 {
   private ScrambleState[] mStates;
-  private int[] mQuatNumber;
+  private int[] mQuatIndex;
   private float[][] mCenters;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -131,18 +131,17 @@ public class TwistySquare2 extends TwistySquare
 
   public Static4D getCubitQuats(int cubit, int[] numLayers)
     {
-    if( mQuatNumber ==null )
+    if( mQuatIndex==null )
       {
-      mQuatNumber = new int[]
+      mQuatIndex = new int[]
         {
         0, 6,
-        0, 9, 6, 3, 17, 14, 23, 20,
-        0, 9, 6, 3, 0, 9, 6, 3,
-        14, 23, 20, 17, 14, 23, 20, 17
+        0, 9, 6, 3,17,14,23,20,
+        0, 9, 6, 3, 0, 9, 6, 3,14, 23, 20, 17, 14, 23, 20, 17
         };
       }
 
-    return mObjectQuats[mQuatNumber[cubit]];
+    return mObjectQuats[mQuatIndex[cubit]];
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/objectlib/objects/TwistyTrajber.java b/src/main/java/org/distorted/objectlib/objects/TwistyTrajber.java
index 4552e701..ecce1f1d 100644
--- a/src/main/java/org/distorted/objectlib/objects/TwistyTrajber.java
+++ b/src/main/java/org/distorted/objectlib/objects/TwistyTrajber.java
@@ -52,7 +52,7 @@ public class TwistyTrajber extends ShapeOctahedron
   private ScrambleState[] mStates;
   private int[] mBasicAngle;
   private float[][] mCuts;
-  private float[][] mCenters;
+  private float[][] mPositions;
   private int[] mQuatIndex;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -206,14 +206,14 @@ public class TwistyTrajber extends ShapeOctahedron
 
   public float[][] getCubitPositions(int[] numLayers)
     {
-    if( mCenters==null )
+    if( mPositions==null )
       {
       int numL = numLayers[0];
       float LEN = numL*0.5f;
 
       if( numL==3 )
         {
-        mCenters = new float[][]
+        mPositions = new float[][]
             {
               {   LEN,       0,   LEN},
               {  -LEN,       0,  -LEN},
@@ -258,7 +258,7 @@ public class TwistyTrajber extends ShapeOctahedron
         final float I = LEN-0.5f*B;
         final float J = SQ2*(LEN-B);
 
-        mCenters = new float[][]
+        mPositions = new float[][]
             {
               {   I  ,  A,  I-B },
               {   I  , -A,  I-B },
@@ -324,7 +324,7 @@ public class TwistyTrajber extends ShapeOctahedron
         }
       }
 
-    return mCenters;
+    return mPositions;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/objectlib/objects/TwistyUltimate.java b/src/main/java/org/distorted/objectlib/objects/TwistyUltimate.java
index 746ac628..cc9626eb 100644
--- a/src/main/java/org/distorted/objectlib/objects/TwistyUltimate.java
+++ b/src/main/java/org/distorted/objectlib/objects/TwistyUltimate.java
@@ -56,7 +56,7 @@ public class TwistyUltimate extends ShapeDodecahedron
   private ScrambleState[] mStates;
   private int[] mBasicAngle;
   private float[][] mCuts;
-  private float[][] mCenters;
+  private float[][] mPositions;
   private int[] mQuatIndex;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -87,9 +87,9 @@ public class TwistyUltimate extends ShapeDodecahedron
 
   public float[][] getCubitPositions(int[] numLayers)
     {
-    if( mCenters==null )
+    if( mPositions==null )
       {
-      mCenters = new float[][]
+      mPositions = new float[][]
          {
            {   0,  -1, 2*G },
            { 2*E,-2*E,-2*E },
@@ -110,7 +110,7 @@ public class TwistyUltimate extends ShapeDodecahedron
          };
       }
 
-    return mCenters;
+    return mPositions;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/objectlib/objects/TwistyVoid.java b/src/main/java/org/distorted/objectlib/objects/TwistyVoid.java
index ca760cca..6f13e86d 100644
--- a/src/main/java/org/distorted/objectlib/objects/TwistyVoid.java
+++ b/src/main/java/org/distorted/objectlib/objects/TwistyVoid.java
@@ -47,7 +47,7 @@ public class TwistyVoid extends ShapeHexahedron
   private ScrambleState[] mStates;
   private int[] mBasicAngle;
   private float[][] mCuts;
-  private float[][] mCenters;
+  private float[][] mPositions;
   private int[] mQuatIndex;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -181,9 +181,9 @@ public class TwistyVoid extends ShapeHexahedron
 
   public float[][] getCubitPositions(int[] numLayers)
     {
-    if( mCenters==null )
+    if( mPositions==null )
       {
-      mCenters = new float[][]
+      mPositions = new float[][]
          {
              { 1.0f, 1.0f, 1.0f},
              { 1.0f, 1.0f,-1.0f},
@@ -209,7 +209,7 @@ public class TwistyVoid extends ShapeHexahedron
          };
       }
 
-    return mCenters;
+    return mPositions;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/objectlib/objects/TwistyWindmill.java b/src/main/java/org/distorted/objectlib/objects/TwistyWindmill.java
index 5f83ba4f..fd5a9dbe 100644
--- a/src/main/java/org/distorted/objectlib/objects/TwistyWindmill.java
+++ b/src/main/java/org/distorted/objectlib/objects/TwistyWindmill.java
@@ -51,7 +51,7 @@ public class TwistyWindmill extends ShapeHexahedron
   private ScrambleState[] mStates;
   private int[] mBasicAngle;
   private float[][] mCuts;
-  private float[][] mCenters;
+  private float[][] mPositions;
   private int[] mQuatIndex;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -165,12 +165,12 @@ public class TwistyWindmill extends ShapeHexahedron
 
   public float[][] getCubitPositions(int[] numLayers)
     {
-    if( mCenters==null )
+    if( mPositions==null )
       {
       final float DIS1 = -X/2 + 1.5f;
       final float DIS2 = -X/2;
 
-      mCenters = new float[][]
+      mPositions = new float[][]
          {
              { DIS1, 1.0f, 1.5f },
              { 1.5f, 1.0f,-DIS1 },
@@ -203,15 +203,16 @@ public class TwistyWindmill extends ShapeHexahedron
          };
       }
 
-    return mCenters;
+    return mPositions;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   public Static4D getCubitQuats(int cubit, int[] numLayers)
     {
-    int I0 =0; int I1 =6; int I2 =5; int I3 =4;
-    if( mQuatIndex==null ) mQuatIndex = new int[] {I0,I1,I2,I3,I0,I1,I2,I3,I0,I1,I2,I3, I0,I1,I2,I3,I0,I1,I2,I3,I0,I1,I2,I3, 0,0 };
+    if( mQuatIndex==null ) mQuatIndex = new int[] { 0,6,5,4,0,6,5,4,0,6,5,4,
+                                                    0,6,5,4,0,6,5,4,0,6,5,4,
+                                                    0,0 };
     return mObjectQuats[mQuatIndex[cubit]];
     }
 
