// gyroid-hex.fe

// Gyroid by Bonnet rotation of hexagonal chunk of D surface.
// After loading, this file will automatically evolve the D surface,
//   do the Bonnet rotation, and show multiple transforms.
// The user can experiment with the transform_expr command to show
// various size pieces of the gyroid.  For increasing amounts, try
//    transform_expr "aaabbbccc"
//    transform_expr "abcabcabc"
// Due to lack of suitable boundary conditions, the surface is not 
// evolvable after doing the Bonnet rotation.

// replication transformations for gyroid
// Rotations and inversions about normal vectors, which are
// invariant for Bonnet rotations (except axes translated).


view_transforms 41 // plus default identity
-1 0 0 -2   0 -1 0 0   0 0 1 0   0 0 0 1   
-1 0 0 -2   0 1 0 2   0 0 -1 0   0 0 0 1   
-1 0 0 -1   0 0 -1 -1   0 -1 0 -1   0 0 0 1   
-1 0 0 -1   0 0 -1 -1   0 -1 0 3   0 0 0 1   
-1 0 0 -1   0 0 -1 3   0 -1 0 -1   0 0 0 1   
-1 0 0 -1   0 0 -1 3   0 -1 0 3   0 0 0 1   
-1 0 0 -1   0 0 1 -1   0 1 0 -3   0 0 0 1   
-1 0 0 -1   0 0 1 -1   0 1 0 1   0 0 0 1   
-1 0 0 -1   0 0 1 3   0 1 0 -3   0 0 0 1   
-1 0 0 -1   0 0 1 3   0 1 0 1   0 0 0 1   
-1 0 0 0   0 -1 0 2   0 0 1 -2   0 0 0 1   
-1 0 0 0   0 -1 0 2   0 0 1 2   0 0 0 1   
-1 0 0 0   0 1 0 0   0 0 -1 -2   0 0 0 1   
-1 0 0 0   0 1 0 0   0 0 -1 2   0 0 0 1   
-1 0 0 1   0 0 -1 1   0 -1 0 -3   0 0 0 1   
-1 0 0 1   0 0 -1 1   0 -1 0 1   0 0 0 1   
-1 0 0 1   0 0 1 1   0 1 0 -1   0 0 0 1   
-1 0 0 1   0 0 1 1   0 1 0 3   0 0 0 1   
-1 0 0 2   0 -1 0 0   0 0 1 0   0 0 0 1   
-1 0 0 2   0 1 0 2   0 0 -1 0   0 0 0 1   
0 0 1 -2   -1 0 0 0   0 -1 0 -2   0 0 0 1   
0 0 1 -2   -1 0 0 0   0 -1 0 2   0 0 0 1   
0 0 1 -2   1 0 0 2   0 1 0 -2   0 0 0 1   
0 0 1 -2   1 0 0 2   0 1 0 2   0 0 0 1   
0 0 1 -1   0 -1 0 1   1 0 0 -3   0 0 0 1   
0 0 1 -1   0 -1 0 1   1 0 0 1   0 0 0 1   
0 0 1 -1   0 1 0 1   -1 0 0 -1   0 0 0 1   
0 0 1 -1   0 1 0 1   -1 0 0 3   0 0 0 1   
0 0 1 0   -1 0 0 2   0 -1 0 0   0 0 0 1   
0 0 1 1   0 -1 0 -1   1 0 0 -1   0 0 0 1   
0 0 1 1   0 -1 0 -1   1 0 0 3   0 0 0 1   
0 0 1 1   0 -1 0 3   1 0 0 -1   0 0 0 1   
0 0 1 1   0 -1 0 3   1 0 0 3   0 0 0 1   
0 0 1 1   0 1 0 -1   -1 0 0 -3   0 0 0 1   
0 0 1 1   0 1 0 -1   -1 0 0 1   0 0 0 1   
0 0 1 1   0 1 0 3   -1 0 0 -3   0 0 0 1   
0 0 1 1   0 1 0 3   -1 0 0 1   0 0 0 1   
0 0 1 2   -1 0 0 0   0 -1 0 -2   0 0 0 1   
0 0 1 2   -1 0 0 0   0 -1 0 2   0 0 0 1   
0 0 1 2   1 0 0 2   0 1 0 -2   0 0 0 1   
0 0 1 2   1 0 0 2   0 1 0 2   0 0 0 1   
// data for D surface patch
vertices
1   1 0 0 fixed
2   1 1 0 fixed
3   0 1 0 fixed
4   0 1 1 fixed
5   0 0 1 fixed
6   1 0 1 fixed

edges
1   1 2 fixed
2   2 3 fixed
3   3 4 fixed
4   4 5 fixed
5   5 6 fixed
6   6 1 fixed

faces
1   1 2 3 4 5 6  frontcolor white backcolor yellow

read



read "adjoint.cmd"

// Evolve D surface
gogoD := { r; g 5; r; g 5; hessian; r; g 5; hessian; }

bangle :=  38.015

// Do Bonnet rotation
bonnet := { 
  unfix vertex;
  unfix edge;
  adjoint;

// center at origin
cx := vertex[7].x; set vertex x x-cx;
cy := vertex[7].y; set vertex y y-cy;
cz := vertex[7].z; set vertex z z-cz;
// scale to unit cube
sc := -1/vertex[1].y;
set vertex x x*sc;
set vertex y y*sc;
set vertex z z*sc;

  // redefine 'g'and stuff so user doesn't accidently try to evolve
  g :::= { printf 
     "This gyroid is not evolvable due to lack of boundary constraints.\n"; 
  };
  r :::= { printf 
     "This gyroid is not evolvable due to lack of boundary constraints.\n"; 
  };
  u :::= { printf 
     "This gyroid is not evolvable due to lack of boundary constraints.\n"; 
  };
  V :::= { printf 
     "This gyroid is not evolvable due to lack of boundary constraints.\n"; 
  };
}

gogoD;
bonnet;
thickness /= 2; 

//set edge color clear where valence == 2;

showq;
show_trans "R"

// coloring facets next to outside edges for easy transform picking
outcolor := {
  foreach edge ee where valence == 1 do set ee.facet color ee.original;
}
  

// Convert from image copies to actual copies of hexagons.
reify := {
   detorus_epsilon := 0.01;
   detorus;
   foreach edge ee where valence == 1 do { fix ee; fix ee.vertex;};
}

  

