commit b3d28a81a0aa97958843b468f79bc7c8e600b99e
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Jan 19 17:17:22 2021 +0100

    Beginnings of Megaminx & Gigaminx

diff --git a/src/main/java/org/distorted/examples/meshfile/FactoryCubit.java b/src/main/java/org/distorted/examples/meshfile/FactoryCubit.java
index e9dcdb0..1d1b9cb 100644
--- a/src/main/java/org/distorted/examples/meshfile/FactoryCubit.java
+++ b/src/main/java/org/distorted/examples/meshfile/FactoryCubit.java
@@ -47,11 +47,11 @@ class FactoryCubit
   private static final float REX_D = 0.2f;
   private static final int   REX_N = 5;
 
-  static final float MINX_C0 = (SQ5-1)/4;
-  static final float MINX_C1 = (SQ5+1)/4;                         // sin(54 deg)
-  static final float MINX_C3 = (float)(Math.sqrt(10-2*SQ5)/4);    // cos(54 deg)
-  static final float MINX_C4 = (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
-  static final float MINX_C5 = (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
+  static final float MINX_C0  = (SQ5-1)/4;
+  static final float SIN54    = (SQ5+1)/4;                         // sin(54 deg)
+  static final float COS54    = (float)(Math.sqrt(10-2*SQ5)/4);    // cos(54 deg)
+  static final float COS_HALFD= (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
+  static final float SIN_HALFD= (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
 
   private static final Static1D RADIUS = new Static1D(1);
 
@@ -734,17 +734,17 @@ class FactoryCubit
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  MeshBase createFacesMinxCorner()
+  MeshBase createFacesKilominxCorner()
     {
     MeshBase[] meshes = new MeshPolygon[6];
 
     float X1= (SQ5+1)/8;
     float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
     float Y2= Y1 - (float)(Math.sqrt(10-2*SQ5)/8);
-    float H = 0.5f*MINX_C1/MINX_C3;
-    float X2= H*MINX_C5;
-    float Y3= H/(2*MINX_C4);
-    float Y4= H*(1/(2*MINX_C4) - MINX_C4);
+    float H = 0.5f* SIN54 / COS54;
+    float X2= H*SIN_HALFD;
+    float Y3= H/(2*COS_HALFD);
+    float Y4= H*(1/(2*COS_HALFD) - COS_HALFD);
 
     float[] vertices0 = { -X1, Y2, 0, -Y1, X1, Y2, 0, Y1 };
     float[] bands0 = computeBands(0.03f,39,0.3f,0.2f,5);
@@ -767,6 +767,34 @@ class FactoryCubit
     return new MeshJoined(meshes);
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  MeshBase createFacesMegaminxCorner()
+    {
+    MeshBase[] meshes = new MeshPolygon[6];
+
+    float Y = COS54/(2*SIN54);
+
+    float[] vertices0 = { -0.5f, 0.0f, 0.0f, -Y, 0.5f, 0.0f, 0.0f, Y };
+    float[] bands0 = computeBands(0.04f,34,0.3f,0.2f,5);
+    float[] bands1 = computeBands(0.00f,34,0.3f,0.2f,2);
+
+    meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
+    meshes[0].setEffectAssociation(0, 1,0);
+    meshes[1] = meshes[0].copy(true);
+    meshes[1].setEffectAssociation(0, 2,0);
+    meshes[2] = meshes[0].copy(true);
+    meshes[2].setEffectAssociation(0, 4,0);
+    meshes[3] = new MeshPolygon(vertices0, bands1, 1, 4);
+    meshes[3].setEffectAssociation(0, 8,0);
+    meshes[4] = meshes[3].copy(true);
+    meshes[4].setEffectAssociation(0,16,0);
+    meshes[5] = meshes[3].copy(true);
+    meshes[5].setEffectAssociation(0,32,0);
+
+    return new MeshJoined(meshes);
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // EFFECTS
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1266,22 +1294,22 @@ class FactoryCubit
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  VertexEffect[] createVertexEffectsMinxCorner()
+  VertexEffect[] createVertexEffectsKilominxCorner()
     {
     VertexEffect[] effect = new VertexEffect[9];
 
-    float H = 0.5f*(MINX_C1/MINX_C3);
+    float H = 0.5f*(SIN54 / COS54);
     float Y1= (float)(Math.sqrt(2+0.4f*SQ5)/4);
-    float Y2= H/(2*MINX_C4);
+    float Y2= H/(2*COS_HALFD);
     float A = (float)(Math.acos(-SQ5/5)*180/Math.PI);  // dihedral angle of a dedecahedron in degrees
     float sin18 = MINX_C0;
     float cos18 = (float)(Math.sqrt(1-MINX_C0*MINX_C0));
-    float LEN   = (float)Math.sqrt(H*H/(MINX_C4*MINX_C4) + 0.25f);
+    float LEN   = (float)Math.sqrt(H*H/(COS_HALFD*COS_HALFD) + 0.25f);
 
     Static3D axisZ = new Static3D(0.0f  , 0.0f , 1.0f);
     Static3D axisY = new Static3D(0.0f  , 1.0f , 0.0f);
     Static3D axisA = new Static3D(-sin18, cos18, 0.0f);
-    Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H*MINX_C5/(MINX_C4*LEN));
+    Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H*SIN_HALFD/(COS_HALFD*LEN));
 
     Static3D move1 = new Static3D(0,-Y1,0);
     Static3D move2 = new Static3D(0,-Y2,0);
@@ -1317,6 +1345,53 @@ class FactoryCubit
     return effect;
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  VertexEffect[] createVertexEffectsMegaminxCorner()
+    {
+    VertexEffect[] effect = new VertexEffect[9];
+
+    float Y = COS54/(2*SIN54);
+    float A = (float)(Math.acos(-SQ5/5)*180/Math.PI);  // dihedral angle of a dedecahedron in degrees
+
+    float sinA = (2*SIN54*SIN54-1)/COS54;
+    float cosA = (float)Math.sqrt(1-sinA*sinA);
+    float LEN  = 0.5f/SIN54;
+
+    Static3D axisA = new Static3D( SIN54, COS54, 0.0f);
+    Static3D axisB = new Static3D(-SIN54, COS54, 0.0f);
+    Static3D axisX = new Static3D(  1.0f,  0.0f, 0.0f);
+
+    Static3D centerU = new Static3D( 0.0f, Y, 0.0f);
+    Static3D centerD = new Static3D( 0.0f,-Y, 0.0f);
+
+    Static3D move1= new Static3D(0.0f, -sinA*LEN, -cosA*LEN );
+    Static3D move2= new Static3D(0.0f, Y , 0.0f );
+
+    Static1D angleD = new Static1D(A);
+    Static1D angleE = new Static1D(360-A);
+    Static1D angleF = new Static1D( (float)((180/Math.PI)*Math.asin(sinA) - 90) );
+
+    effect[0] = new VertexEffectScale ( new Static3D( 1, 1,-1) );
+    effect[1] = new VertexEffectRotate(angleE, axisA, centerU);
+    effect[2] = new VertexEffectRotate(angleD, axisB, centerU);
+    effect[3] = new VertexEffectMove(move1);
+    effect[4] = new VertexEffectRotate(angleE, axisA, centerD);
+    effect[5] = new VertexEffectRotate(angleD, axisB, centerD);
+    effect[6] = new VertexEffectRotate(angleF, axisX, centerD);
+    effect[7] = new VertexEffectMove(move2);
+    effect[8] = new VertexEffectScale(SIN54);
+
+    effect[0].setMeshAssociation(  3,-1);  // meshes 0,1
+    effect[1].setMeshAssociation( 16,-1);  // mesh 4
+    effect[2].setMeshAssociation( 32,-1);  // mesh 5
+    effect[3].setMeshAssociation( 56,-1);  // meshes 3,4,5
+    effect[4].setMeshAssociation(  1,-1);  // mesh 0
+    effect[5].setMeshAssociation(  2,-1);  // mesh 1
+
+    return effect;
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // OBJECTS
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1667,17 +1742,17 @@ class FactoryCubit
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  MeshBase createMinxCornerMesh()
+  MeshBase createKilominxCornerMesh()
     {
-    MeshBase mesh = createFacesMinxCorner();
-    VertexEffect[] effects = createVertexEffectsMinxCorner();
+    MeshBase mesh = createFacesKilominxCorner();
+    VertexEffect[] effects = createVertexEffectsKilominxCorner();
     for( VertexEffect effect : effects ) mesh.apply(effect);
 
-    float A = (2*SQ3/3)*MINX_C1;
+    float A = (2*SQ3/3)* SIN54;
     float B = 0.4f;
-    float X = MINX_C5*MINX_C1*MINX_C3;
-    float Y = MINX_C1*MINX_C1 - 0.5f;
-    float Z = MINX_C4*MINX_C1*MINX_C3;
+    float X = SIN_HALFD* SIN54 * COS54;
+    float Y = SIN54 * SIN54 - 0.5f;
+    float Z = COS_HALFD* SIN54 * COS54;
 
     Static3D center = new Static3D(0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B);
 
@@ -1691,6 +1766,35 @@ class FactoryCubit
 
     //mesh.mergeEffComponents();
 
+    return mesh;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  MeshBase createMegaminxCornerMesh()
+    {
+    MeshBase mesh = createFacesMegaminxCorner();
+    VertexEffect[] effects = createVertexEffectsMegaminxCorner();
+    for( VertexEffect effect : effects ) mesh.apply(effect);
+
+    float A = (2*SQ3/3)* SIN54;
+    float B = 0.4f;
+    float X = SIN_HALFD* SIN54 * COS54;
+    float Y = SIN54 * SIN54 - 0.5f;
+    float Z = COS_HALFD* SIN54 * COS54;
+
+    Static3D center = new Static3D(0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B);
+
+    Static3D[] vertices = new Static3D[4];
+    vertices[0] = new Static3D( 0.0f, 0.0f, 0.0f);
+    vertices[1] = new Static3D( 0.0f,-0.5f, 0.0f);
+    vertices[2] = new Static3D(-X   , Y   ,-Z   );
+    vertices[3] = new Static3D(+X   , Y   ,-Z   );
+
+    roundCorners(mesh,center,vertices,0.04f,0.10f);
+
+    //mesh.mergeEffComponents();
+
     return mesh;
     }
   }
diff --git a/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java b/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
index 6d0d8e1..9b256ef 100644
--- a/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
+++ b/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
@@ -328,7 +328,7 @@ class MeshFileRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Excep
     private void createMesh()
       {
       FactoryCubit factory = FactoryCubit.getInstance();
-      mMesh = factory.createMinxCornerMesh();
+      mMesh = factory.createMegaminxCornerMesh();
 
       //mMesh = createStaticMesh();
 
