Beispiel #1
0
        public static void PovRayModel()
        {
            Vector3D cen = HoneycombPaper.InteriorPointBall;

            cen = H3Models.BallToUHS(cen);
            Sphere[] simplex = Simplex(ref cen);

            H3.Cell[] simplicesFinal = GenTruss(simplex, null, cen, ball: true);
            string    fileName       = "350cell.pov";

            System.IO.File.Delete(fileName);
            foreach (H3.Cell cell in simplicesFinal)
            {
                //int[] include = new int[] { 0, 1, 2, 3 };
                int[] include = new int[] { 0 };
                PovRay.AppendSimplex(cell.Facets.Select(f => f.Sphere).ToArray(), cell.Center, include, fileName);
            }

            /*
             * HashSet<H3.Cell.Edge> axes = new HashSet<H3.Cell.Edge>( new H3.Cell.EdgeEqualityComparer() );
             * H3.Cell.Edge axis = new H3.Cell.Edge( new Vector3D( 0, 0, -1 ), new Vector3D( 0, 0, 1 ) );
             * axes.Add( axis );
             * foreach( int[] reflections in TrussReflections() )
             * {
             *      Vector3D s = axis.Start, e = axis.End;
             *      foreach( int ri in reflections )
             *      {
             *              s = simplex[ri].ReflectPoint( s );
             *              e = simplex[ri].ReflectPoint( e );
             *      }
             *      axes.Add( new H3.Cell.Edge( s, e ) );
             * }
             * PovRay.WriteH3Edges( new PovRay.Parameters { AngularThickness = 0.045 }, axes.ToArray(), "axes.pov" );
             *
             * H3.Cell.Edge[] fibers = new H3.Cell.Edge[] { axis };
             * fibers = Recurse.CalcEdges( simplex.Skip(1).ToArray(), fibers );
             * PovRay.WriteH3Edges( new PovRay.Parameters { AngularThickness = 0.025 }, fibers, "axes.pov" );*/
        }
Beispiel #2
0
        private static void CreateSimplex(HoneycombDef imageData)
        {
            int p = imageData.P;
            int q = imageData.Q;
            int r = imageData.R;

            Vector3D cen  = InteriorPointBall;
            bool     ball = true;

            Sphere[] simplex = SimplexCalcs.Mirrors(p, q, r, ref cen, moveToBall: ball);

            // Offset as we do for the boundary images.
            //Sphere s = H3Models.UHSToBall( simplex[0] );
            //s = CoxeterImages.GeodesicOffset( s, 0.02, ball: true );

            if (m_toKlein)
            {
                simplex = simplex.Select(s => H3Models.BallToKlein(s)).ToArray();
            }

            int[] include = new int[] { 0, 1, 2, 3 };                   // All facets
            //int[] include = new int[] { 1 };
            File.Delete("simplex.pov");
            PovRay.AppendSimplex(simplex, cen, include, "simplex.pov");

            bool includeEdges = false;

            if (includeEdges)
            {
                H3.Cell.Edge[] edges = SimplexCalcs.SimplexEdgesUHS(p, q, r);
                PovRay.WriteEdges(new PovRay.Parameters {
                    Halfspace = true, AngularThickness = 0.03
                },
                                  Geometry.Hyperbolic, edges, "simplex.pov", append: true);
            }
        }
Beispiel #3
0
        /// <summary>
        /// This is like the GenCell method, but super hacked up for the Catacombs image with Henry.
        /// </summary>
        internal static void GenCellCatacombs(Sphere[] simplex, bool ball)
        {
            // We don't want to include the first mirror (which reflects across cells).
            Sphere[] mirrors    = simplex.Skip(1).ToArray();
            Sphere[] allMirrors = simplex.ToArray();

            // Simplices will be the "cells" in Recurse.CalcCells.
            H3.Cell.Facet[] simplexFacets = simplex.Select(m => new H3.Cell.Facet(m)).ToArray();

            // Offset cell boundary ever so slightly, to avoid artifacts of adjacent cells.
            Sphere toReflectLater = simplexFacets[0].Sphere.Clone();

            //simplexFacets[0].Sphere = CoxeterImages.GeodesicOffset( simplexFacets[0].Sphere, ball ? -1e-6 : 1e-7, ball );

            H3.Cell startingCell = new H3.Cell(simplexFacets);
            startingCell = startingCell.Clone();                // So our mirrors don't get munged after we reflect around later.
            Vector3D cen = new Vector3D(0.05, 0.01, -0.05);     //	373, 438

            //Vector3D cen = new Vector3D( 0.05, 0.01, 100 );		//	637
            //cen.RotateXY( Math.PI / 2 );	// only if we also rotate simplex mirrors.  XXX - make a setting.
            startingCell.Center = cen;
            H3.Cell[] simplices = Recurse.CalcCells(mirrors, new H3.Cell[] { startingCell }, new Recurse.Settings()
            {
                Ball = ball
            });

            List <H3.Cell> simplicesFinal = new List <H3.Cell>();
            List <int[]>   reflectionSets = new List <int[]>();

            // 1 reflects in x-axis
            // 3, 1 rotates right
            // 1, 3 rotates left

            reflectionSets.Add(new int[] { 0, 3, 1, 3, 1, 0, 1, 3 });
            reflectionSets.Add(new int[] { 0, 3, 1, 2, 3, 1, 0, 3, 1, 2, 0, 3 });

            // 2
            reflectionSets.Add(new int[] { 0, 3, 1, 3, 1, 3, 1, 0, 3, 1, 3, 1, 3, 1, 2, 3, 1, 3, 2, 3, 1 });
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 3, 1, 0,		3, 1, 3, 1, 0,	3, 1, 3, 1, 3, 1, 2,	3, 1, 3, 2, 3, 1 } );

            // 3
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 3, 1, 0, 3, 1, 3, 1, 0, 3, 1, 2 } );
            reflectionSets.Add(new int[] { 0, 3, 1, 3, 1, 3, 0, 3, 1, 3, 1, 0, 2 });
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 3, 1, 0, 3, 1, 2 } );

            // 5
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 3, 1, 0, 1, 2, 3, 1 } );

            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 0, 2, 3, 1 } );
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 0, 3, 1, 3, 1, 3, 1, 2, 3, 1, 3, 1, 0, 1, 3 } );	// baby
            //reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 0, 3, 1, 3, 1, 3, 1, 2 } );	// maybe
            //reflectionSets.Add( new int[] { 0, 3, 1, 2, 3, 1, 0, 2, 1, 3 } );
            //reflectionSets.Add( new int[] { 0, 3, 1, 2, 3, 1, 0, 3, 1, 2 } );		// not great orientation
            // reflectionSets.Add( new int[] { 0, 3, 1, 3, 1, 2 } );	// big

            bool ceiling = true;

            if (ceiling)
            {
                simplicesFinal = simplices.ToList();
            }
            else
            {
                foreach (int[] set in reflectionSets)
                {
                    List <H3.Cell> copy = simplices.Select(s => s.Clone()).ToList();
                    foreach (int r in set)
                    {
                        foreach (H3.Cell cell in copy)
                        {
                            cell.Reflect(allMirrors[r]);
                        }
                    }
                    simplicesFinal.AddRange(copy);
                }
            }

            /*
             * // A second cell.
             * //toReflectLater = simplices[45].Facets[0].Sphere.Clone();
             * //toReflectLater = simplices.First( s => s.Depth == 2 ).Facets[0].Sphere.Clone();
             * foreach( H3.Cell cell in simplices )
             *      cell.Reflect( toReflectLater );
             *
             * // A third cell.
             * toReflectLater = simplices[40].Facets[0].Sphere.Clone();
             * //toReflectLater = simplices.First( s => s.Depth == 4 ).Facets[0].Sphere.Clone();
             * foreach( H3.Cell cell in simplices )
             *      cell.Reflect( toReflectLater );
             *
             * foreach( H3.Cell cell in simplices )
             *      cell.Depths = new int[4];
             * List<H3.Cell> simplicesFinal = Recurse.CalcCells2( mirrors, simplices ).ToList();
             * simplicesFinal = simplicesFinal.Where( s => s.Depths[0] % 3 == 1 && s.Depths[1] % 2 == 0 && s.Depths[2] % 2 == 1 ).ToList();
             */

            /*
             * List<H3.Cell> simplicesFinal = new List<H3.Cell>();
             * //for( int d = 0; d < 1; d+=2 )
             * int d = 0;
             * {
             *      //Sphere toReflect = simplices.First( s => s.Depth == d ).Facets[0].Sphere.Clone();
             *      //Sphere toReflect = simplices.Where( s => s.Depth == d ).Skip(1).Take(1).First().Facets[0].Sphere.Clone();
             *      List<H3.Cell> reflectionCells = simplices.Where( s => s.Depths[1] == d && s.Depths[0] % 2 == 0 ).Skip(0).Take(1).ToList();
             *      foreach( Sphere toReflect in reflectionCells.Select( c => c.Facets[0].Sphere.Clone() ) )
             *      {
             *              List<H3.Cell> thisCell = new List<H3.Cell>();
             *              foreach( H3.Cell cell in simplices )
             *              {
             *                      H3.Cell clone = cell.Clone();
             *                      clone.Reflect( toReflect );
             *                      thisCell.Add( clone );
             *              }
             *
             *              //Sphere toReflect2 = thisCell.First( s => s.Depth1 == d + 3 && s.Depth0 % 2 == 0 ).Facets[0].Sphere.Clone();
             *              //List<H3.Cell> reflectionCellsTemp = simplices.Where( s => Math.Abs( s.Depths[1] - d ) == 2 && s.Depths[0] % 2 == 0 ).ToList();
             *              List<H3.Cell> reflectionCellsTemp = simplices.Where( s => s.Depths[1] == 2 && s.Depths[1] == s.Depths[0] + s.Depths[2] ).ToList();
             *              List<H3.Cell> reflectionCells2 = reflectionCellsTemp;//.Where( ( x, i ) => i % 3 == 0 ).ToList(); // .Skip( 5 ).Take( 5 ).ToList();
             *              foreach( Sphere toReflect2 in reflectionCells2.Select( c => c.Facets[0].Sphere.Clone() ) )
             *              //Sphere toReflect2 = toReflectLater;
             *              {
             *                      foreach( H3.Cell cell in thisCell )
             *                      {
             *                              H3.Cell clone = cell.Clone();
             *                              clone.Reflect( toReflect2 );
             *                              simplicesFinal.Add( clone );
             *                      }
             *              }
             *      }
             * }*/

            int count = 0;

            foreach (H3.Cell cell in simplicesFinal)
            {
                count++;

                //if( count % 2 == 0 )
                //	continue;

                /*if( count < 1 )
                 *      continue;
                 * if( count > 30 )
                 *      return;
                 */
                //int[] include = new int[] { 0, 1, 2, 3 };
                int[] include = new int[] { 0 };
                PovRay.AppendSimplex(cell.Facets.Select(f => f.Sphere).ToArray(), cell.Center, include, "cell.pov");
            }
        }