GenerateInternal() public method

public GenerateInternal ( TilingConfig config, Polytope projection = Polytope.Projection.FaceCentered ) : void
config TilingConfig
projection Polytope
return void
Exemplo n.º 1
0
        private static void GetAssociatedTiling(int p, int q, int maxTiles, out Tiling tiling)
        {
            TilingConfig tilingConfig = new TilingConfig(p, q, maxTiles: maxTiles);

            tiling = new Tiling();
            tiling.GenerateInternal(tilingConfig, p == 6 ? Polytope.Projection.VertexCentered : Polytope.Projection.FaceCentered);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Make an edge mesh of a regular tiling.
        /// </summary>
        public static Mesh MakeEdgeMesh( int p, int q )
        {
            Mesh mesh = new Mesh();

            int maxTiles = 400;

            Tiling tiling = new Tiling();
            TilingConfig config = new TilingConfig( p, q, maxTiles: maxTiles );
            config.Shrink = 0.6;
            tiling.GenerateInternal( config );

            TilingConfig boundaryConfig = new TilingConfig( 14, 7, maxTiles: 1 );
            boundaryConfig.Shrink = 1.01;
            Tile boundary = Tiling.CreateBaseTile( boundaryConfig );

            AddSymmetryTriangles( mesh, tiling, boundary.Drawn );
            //AddSymmetryTriangles( mesh, tiling, null );
            return mesh;

            HashSet<Vector3D> completed = new HashSet<Vector3D>();
            int count = 0;
            foreach( Tile tile in tiling.Tiles )
            {
                MeshEdges( mesh, tile, completed, null );
                count++;
                if( count >= maxTiles )
                    break;
            }

            return mesh;
        }
Exemplo n.º 3
0
        public static void Cell633()
        {
            TilingConfig config = new TilingConfig( 6, 3, maxTiles: 20000 );
            Tiling tiling = new Tiling();
            tiling.GenerateInternal( config, Polytope.Projection.VertexCentered );

            double edgeLength = Honeycomb.EdgeLength( 6, 3, 3 );

            double z = 0.25;
            double offset = H3Models.UHS.ToEHorizontal( edgeLength, z );
            double scale = offset / tiling.Tiles.First().Boundary.Segments.First().Length;
            foreach( Tile tile in tiling.Tiles )
                tile.Transform( Mobius.Scale( scale ) );

            Vector3D dummy;
            double radius;
            H3Models.UHS.Geodesic( new Vector3D( 0, 0, z ), new Vector3D( scale, 0, z ), out dummy, out radius );
            Vector3D midradius = H3Models.UHSToBall( new Vector3D( 0, 0, radius ) );
            double temp = midradius.Z;
            double temp2 = ( 1 - temp ) / 2;
            double temp3 = temp + temp2;
            double temp4 = temp3;

            Vector3D circumradius = H3Models.UHSToBall( new Vector3D( 0, 0, z ) );
            temp = circumradius.Z;
            temp2 = ( 1 - temp ) / 2;
            temp3 = temp + temp2;
            temp4 = temp3;

            // Checking
            /*
            Vector3D test = new Vector3D( offset, 0, z );
            test = H3Models.UHSToBall( test );
            double edgeLength2 = DonHatch.e2hNorm( test.Abs() );
            edgeLength2 += 0;
            */

            HashSet<H3.Cell.Edge> edges = new HashSet<H3.Cell.Edge>();
            foreach( Tile tile in tiling.Tiles )
                foreach( Segment seg in tile.Boundary.Segments )
                {
                    H3.Cell.Edge edge = new H3.Cell.Edge(
                        H3Models.UHSToBall( seg.P1 + new Vector3D( 0, 0, z ) ),
                        H3Models.UHSToBall( seg.P2 + new Vector3D( 0, 0, z ) ) );
                    edges.Add( edge );
                }

            PovRay.WriteH3Edges( new PovRay.Parameters(), edges.ToArray(), "edges.pov" );
        }
Exemplo n.º 4
0
        /// <summary>
        /// A static helper to generate two dual tilings.
        /// </summary>
        /// <remarks>{p,q} will have a vertex at the center.</remarks>
        /// <remarks>{q,p} will have its center at the center.</remarks>
        public static void MakeDualTilings(out Tiling tiling1, out Tiling tiling2, int p, int q)
        {
            tiling1 = new Tiling();
            tiling2 = new Tiling();

            int          maxTiles = 2000;
            TilingConfig config1  = new TilingConfig(p, q, maxTiles);
            TilingConfig config2  = new TilingConfig(q, p, maxTiles);

            tiling1.GenerateInternal(config1, Polytope.Projection.FaceCentered);
            tiling2.GenerateInternal(config2, Polytope.Projection.VertexCentered);

            /*
             * Circle c = new Circle();
             * c.Radius = .9;
             * tiling1.Clip( c );
             * tiling2.Clip( c );
             */
        }
Exemplo n.º 5
0
        /// <summary>
        /// Make an edge mesh of a regular tiling.
        /// </summary>
        public static Mesh MakeEdgeMesh(int p, int q)
        {
            Mesh mesh = new Mesh();

            int maxTiles = 400;

            Tiling       tiling = new Tiling();
            TilingConfig config = new TilingConfig(p, q, maxTiles: maxTiles);

            config.Shrink = 0.6;
            tiling.GenerateInternal(config);

            TilingConfig boundaryConfig = new TilingConfig(14, 7, maxTiles: 1);

            boundaryConfig.Shrink = 1.01;
            Tile boundary = Tiling.CreateBaseTile(boundaryConfig);

            AddSymmetryTriangles(mesh, tiling, boundary.Drawn);
            //AddSymmetryTriangles( mesh, tiling, null );
            return(mesh);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Make an edge mesh of a regular tiling.
        /// </summary>
        public static Mesh MakeEdgeMesh(int p, int q)
        {
            Mesh mesh = new Mesh();

            int maxTiles = 400;

            Tiling       tiling = new Tiling();
            TilingConfig config = new TilingConfig(p, q, maxTiles: maxTiles);

            config.Shrink = 0.6;
            tiling.GenerateInternal(config);

            TilingConfig boundaryConfig = new TilingConfig(14, 7, maxTiles: 1);

            boundaryConfig.Shrink = 1.01;
            Tile boundary = Tiling.CreateBaseTile(boundaryConfig);

            AddSymmetryTriangles(mesh, tiling, boundary.Drawn);
            //AddSymmetryTriangles( mesh, tiling, null );
            return(mesh);

            HashSet <Vector3D> completed = new HashSet <Vector3D>();
            int count = 0;

            foreach (Tile tile in tiling.Tiles)
            {
                MeshEdges(mesh, tile, completed, null);
                count++;
                if (count >= maxTiles)
                {
                    break;
                }
            }

            return(mesh);
        }
Exemplo n.º 7
0
        private static Sphere[] SphericalCellFacetMirrors( HoneycombDef imageData )
        {
            int p = imageData.P;
            int q = imageData.Q;
            int r = imageData.R;

            double inRadius = Honeycomb.InRadius( p, q, r );
            //inRadius *= 1.4;	// Experimenting with {3,3,u}

            Tiling tiling = new Tiling();
            TilingConfig config = new TilingConfig( p, q );
            tiling.GenerateInternal( config, imageData.Projection );

            Sphere[] mirrors = H3.GenFacetSpheres( tiling, inRadius )
                .Select( f => f.Sphere ).ToArray();

            return mirrors;
        }
Exemplo n.º 8
0
        // https://plus.google.com/u/0/117663015413546257905/posts/BnCEkdNiTZ2
        public static void TwinDodecs()
        {
            Tiling tiling = new Tiling();
            TilingConfig config = new TilingConfig( 5, 3 );
            tiling.GenerateInternal( config, Polytope.Projection.VertexCentered );	// Vertex-centered makes infinities tricky

            Dodec dodec = new Dodec();
            foreach( Tile tile in tiling.Tiles )
            foreach( Segment seg in tile.Boundary.Segments )
            {
                Vector3D p1 = seg.P1, p2 = seg.P2;
                if( Infinity.IsInfinite( p1 ) )
                    p1 = Infinity.InfinityVector;
                if( Infinity.IsInfinite( p2 ) )
                    p2 = Infinity.InfinityVector;

                dodec.Verts.Add( p1 );
                dodec.Verts.Add( p2 );
                dodec.Midpoints.Add( Halfway( p1, p2 ) );
            }

            // Now recursively add more vertices.
            HashSet<Vector3D> allVerts = new HashSet<Vector3D>();
            foreach( Vector3D v in dodec.Verts )
                allVerts.Add( v );
            RecurseTwins( allVerts, dodec, 0 );

            using( StreamWriter sw = File.CreateText( "dual_dodecs_points_sphere.pov" ) )
            {
                foreach( Vector3D vert in allVerts )
                {
                    Vector3D onSphere = Sterographic.PlaneToSphereSafe( vert );
                    sw.WriteLine( PovRay.Sphere( new Sphere() { Center = onSphere, Radius = 0.01 } ) );

                    //if( !Infinity.IsInfinite( vert ) )
                    //	sw.WriteLine( PovRay.Sphere( new Sphere() { Center = vert, Radius = 0.01 } ) );
                }
            }
        }
Exemplo n.º 9
0
        public static void Generate(EHoneycomb honeycomb, H3.Settings settings)
        {
            // XXX - Block the same as in H3.  Share code better.
            H3.Cell template = null;
            {
                int p, q, r;
                Honeycomb.PQR(honeycomb, out p, out q, out r);

                // Get data we need to generate the honeycomb.
                Polytope.Projection projection = Polytope.Projection.FaceCentered;
                double phi, chi, psi;
                H3.HoneycombData(honeycomb, out phi, out chi, out psi);

                H3.SetupCentering(honeycomb, settings, phi, chi, psi, ref projection);

                Tiling       tiling = new Tiling();
                TilingConfig config = new TilingConfig(p, q);
                tiling.GenerateInternal(config, projection);

                H3.Cell first = new H3.Cell(p, H3.GenFacets(tiling));
                first.ToSphere();                       // Work in ball model.
                first.ScaleToCircumSphere(1.0);
                first.ApplyMobius(settings.Mobius);

                template = first;
            }

            // Center
            Vector3D center = template.Center;

            // Face
            H3.Cell.Facet facet = template.Facets[0];
            Sphere        s     = H3Models.Ball.OrthogonalSphereInterior(facet.Verts[0], facet.Verts[1], facet.Verts[2]);
            Vector3D      face  = s.Center;

            face.Normalize();
            face *= DistOriginToOrthogonalSphere(s.Radius);

            // Edge
            Circle3D c;

            H3Models.Ball.OrthogonalCircleInterior(facet.Verts[0], facet.Verts[1], out c);
            Vector3D edge = c.Center;

            edge.Normalize();
            edge *= DistOriginToOrthogonalSphere(c.Radius);

            // Vertex
            Vector3D vertex = facet.Verts[0];

            Tet fundamental = new Tet(center, face, edge, vertex);

            // Recurse.
            int level = 1;
            Dictionary <Tet, int> completedTets = new Dictionary <Tet, int>(new TetEqualityComparer());

            completedTets.Add(fundamental, level);
            List <Tet> tets = new List <Tet>();

            tets.Add(fundamental);
            ReflectRecursive(level, tets, completedTets, settings);

            Shapeways mesh = new Shapeways();

            foreach (KeyValuePair <Tet, int> kvp in completedTets)
            {
                if (Utils.Odd(kvp.Value))
                {
                    continue;
                }

                Tet tet = kvp.Key;

                // XXX - really want sphere surfaces here.
                mesh.Mesh.Triangles.Add(new Mesh.Triangle(tet.Verts[0], tet.Verts[1], tet.Verts[2]));
                mesh.Mesh.Triangles.Add(new Mesh.Triangle(tet.Verts[0], tet.Verts[3], tet.Verts[1]));
                mesh.Mesh.Triangles.Add(new Mesh.Triangle(tet.Verts[0], tet.Verts[2], tet.Verts[3]));
                mesh.Mesh.Triangles.Add(new Mesh.Triangle(tet.Verts[1], tet.Verts[3], tet.Verts[2]));
            }

            mesh.Mesh.Scale(settings.Scale);
            STL.SaveMeshToSTL(mesh.Mesh, H3.m_baseDir + "fundamental" + ".stl");
        }
Exemplo n.º 10
0
        public static void Polarity()
        {
            TilingConfig config = new TilingConfig( 3, 7, 50 );
            Tiling tiling = new Tiling();
            tiling.GenerateInternal( config );

            List<Vector3D> points = new List<Vector3D>();
            List<H3.Cell.Edge> edges = new List<H3.Cell.Edge>();

            foreach( Polygon p in tiling.Tiles.Select( t => t.Boundary ) )
            foreach( Segment s in p.Segments )
            foreach( Vector3D v in s.Subdivide( 25 ) )
            {
                Vector3D klein = HyperbolicModels.PoincareToKlein( v );
                H3.Cell.Edge e = Dual( klein );
                points.Add( klein );
                edges.Add( e );
            }

            using( StreamWriter sw = File.CreateText( "polarity.pov" ) )
            {
                double rad = 0.01;
                foreach( Vector3D vert in points )
                    sw.WriteLine( PovRay.Sphere( new Sphere() { Center = vert, Radius = rad } ) );
                foreach( H3.Cell.Edge edge in edges )
                    sw.WriteLine( PovRay.Cylinder( edge.Start, edge.End, rad/2 ) );
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// A static helper to generate two dual tilings.
        /// </summary>
        /// <remarks>{p,q} will have a vertex at the center.</remarks>
        /// <remarks>{q,p} will have its center at the center.</remarks>
        public static void MakeDualTilings( out Tiling tiling1, out Tiling tiling2, int p, int q )
        {
            tiling1 = new Tiling();
            tiling2 = new Tiling();

            int maxTiles = 2000;
            TilingConfig config1 = new TilingConfig( p, q, maxTiles );
            TilingConfig config2 = new TilingConfig( q, p, maxTiles );
            tiling1.GenerateInternal( config1, Polytope.Projection.FaceCentered );
            tiling2.GenerateInternal( config2, Polytope.Projection.VertexCentered );

            /*
            Circle c = new Circle();
            c.Radius = .9;
            tiling1.Clip( c );
            tiling2.Clip( c );
            */
        }