コード例 #1
0
ファイル: H3Supp.cs プロジェクト: remuladgryta/MagicTile
 public static bool IsExotic(EHoneycomb honeycomb)
 {
     return
         (honeycomb == EHoneycomb.H444 ||
          honeycomb == EHoneycomb.H636 ||
          honeycomb == EHoneycomb.H363);
 }
コード例 #2
0
ファイル: Honeycomb.cs プロジェクト: remuladgryta/MagicTile
        public static double EdgeLength(EHoneycomb honeycomb)
        {
            int p, q, r;

            PQR(honeycomb, out p, out q, out r);
            return(EdgeLength(p, q, r));
        }
コード例 #3
0
ファイル: Honeycomb.cs プロジェクト: remuladgryta/MagicTile
        public static double CircumRadius(EHoneycomb honeycomb)
        {
            int p, q, r;

            PQR(honeycomb, out p, out q, out r);
            return(CircumRadius(p, q, r));
        }
コード例 #4
0
ファイル: H3Supp.cs プロジェクト: remuladgryta/MagicTile
        private static void GetAssociatedTiling(EHoneycomb honeycomb, out Tiling tiling, out Tile baseTile)
        {
            int p, q;

            GetPQ(honeycomb, out p, out q);
            TilingConfig tilingConfig = new TilingConfig(p, q, maxTiles: m_params.MaxTiles);

            tiling = new Tiling();
            tiling.Generate(tilingConfig);

            baseTile = Tiling.CreateBaseTile(tilingConfig);
        }
コード例 #5
0
ファイル: Honeycomb.cs プロジェクト: remuladgryta/MagicTile
        public static void PQR(EHoneycomb honeycomb, out int p, out int q, out int r)
        {
            switch (honeycomb)
            {
            case EHoneycomb.H435:
                p = 4; q = 3; r = 5; return;

            case EHoneycomb.H534:
                p = 5; q = 3; r = 4; return;

            case EHoneycomb.H535:
                p = 5; q = 3; r = 5; return;

            case EHoneycomb.H353:
                p = 3; q = 5; r = 3; return;

            case EHoneycomb.H336:
                p = 3; q = 3; r = 6; return;

            case EHoneycomb.H436:
                p = 4; q = 3; r = 6; return;

            case EHoneycomb.H536:
                p = 5; q = 3; r = 6; return;

            case EHoneycomb.H344:
                p = 3; q = 4; r = 4; return;

            case EHoneycomb.H444:
                p = 4; q = 4; r = 4; return;

            case EHoneycomb.H363:
                p = 3; q = 6; r = 3; return;

            case EHoneycomb.H636:
                p = 6; q = 3; r = 6; return;

            case EHoneycomb.H337:
                p = 3; q = 3; r = 7; return;

            case EHoneycomb.H33I:
                p = 3; q = 3; r = -1; return;
            }

            throw new System.ArgumentException();
        }
コード例 #6
0
ファイル: Honeycomb.cs プロジェクト: remuladgryta/MagicTile
        public static string String(EHoneycomb honeycomb, bool dual)
        {
            switch (honeycomb)
            {
            case EHoneycomb.H435:
                return(dual ? "{5,3,4}" : "{4,3,5}");

            case EHoneycomb.H534:
                return(dual ? "{4,3,5}" : "{5,3,4}");

            case EHoneycomb.H535:
                return("{5,3,5}");

            case EHoneycomb.H353:
                return("{3,5,3}");

            case EHoneycomb.H336:
                return(dual ? "{6,3,3}" : "{3,3,6}");

            case EHoneycomb.H436:
                return(dual ? "{6,3,4}" : "{4,3,6}");

            case EHoneycomb.H536:
                return(dual ? "{6,3,5}" : "{5,3,6}");

            case EHoneycomb.H344:
                return(dual ? "{4,4,3}" : "{3,4,4}");

            case EHoneycomb.H444:
                return("{4,4,4}");

            case EHoneycomb.H636:
                return("{6,3,6}");

            case EHoneycomb.H363:
                return("{3,6,3}");

            case EHoneycomb.H337:
                return(dual ? "{7,3,3}" : "{3,3,7}");

            case EHoneycomb.H33I:
                return(dual ? "{inf,3,3}" : "{3,3,inf}");
            }

            throw new System.ArgumentException("Unknown honeycomb type");
        }
コード例 #7
0
ファイル: H3Supp.cs プロジェクト: remuladgryta/MagicTile
        private static void GetPQ(EHoneycomb honeycomb, out int p, out int q)
        {
            int r;

            Honeycomb.PQR(honeycomb, out p, out q, out r);
        }
コード例 #8
0
ファイル: Honeycomb.cs プロジェクト: roice3/Honeycombs
 public static double EdgeLength( EHoneycomb honeycomb )
 {
     int p, q, r;
     PQR( honeycomb, out p, out q, out r );
     return EdgeLength( p, q, r );
 }
コード例 #9
0
ファイル: Honeycomb.cs プロジェクト: roice3/Honeycombs
 public static double CircumRadius( EHoneycomb honeycomb )
 {
     int p, q, r;
     PQR( honeycomb, out p, out q, out r );
     return CircumRadius( p, q, r );
 }
コード例 #10
0
ファイル: Honeycomb.cs プロジェクト: roice3/Honeycombs
        public static string String( EHoneycomb honeycomb, bool dual )
        {
            switch( honeycomb )
            {
                case EHoneycomb.H435:
                    return dual ? "{5,3,4}" : "{4,3,5}";
                case EHoneycomb.H534:
                    return dual ? "{4,3,5}" : "{5,3,4}";
                case EHoneycomb.H535:
                    return "{5,3,5}";
                case EHoneycomb.H353:
                    return "{3,5,3}";
                case EHoneycomb.H336:
                    return dual ? "{6,3,3}" : "{3,3,6}";
                case EHoneycomb.H436:
                    return dual ? "{6,3,4}" : "{4,3,6}";
                case EHoneycomb.H536:
                    return dual ? "{6,3,5}" : "{5,3,6}";
                case EHoneycomb.H344:
                    return dual ? "{4,4,3}" : "{3,4,4}";
                case EHoneycomb.H444:
                    return "{4,4,4}";
                case EHoneycomb.H636:
                    return "{6,3,6}";
                case EHoneycomb.H363:
                    return "{3,6,3}";
                case EHoneycomb.H337:
                    return dual ? "{7,3,3}" : "{3,3,7}";
                case EHoneycomb.H33I:
                    return dual ? "{inf,3,3}" : "{3,3,inf}";
            }

            throw new System.ArgumentException( "Unknown honeycomb type" );
        }
コード例 #11
0
ファイル: Honeycomb.cs プロジェクト: roice3/Honeycombs
        public static void PQR( EHoneycomb honeycomb, out int p, out int q, out int r )
        {
            switch( honeycomb )
            {
                case EHoneycomb.H435:
                    p = 4; q = 3; r = 5; return;
                case EHoneycomb.H534:
                    p = 5; q = 3; r = 4; return;
                case EHoneycomb.H535:
                    p = 5; q = 3; r = 5; return;
                case EHoneycomb.H353:
                    p = 3; q = 5; r = 3; return;
                case EHoneycomb.H336:
                    p = 3; q = 3; r = 6; return;
                case EHoneycomb.H436:
                    p = 4; q = 3; r = 6; return;
                case EHoneycomb.H536:
                    p = 5; q = 3; r = 6; return;
                case EHoneycomb.H344:
                    p = 3; q = 4; r = 4; return;
                case EHoneycomb.H444:
                    p = 4; q = 4; r = 4; return;
                case EHoneycomb.H363:
                    p = 3; q = 6; r = 3; return;
                case EHoneycomb.H636:
                    p = 6; q = 3; r = 6; return;
                case EHoneycomb.H337:
                    p = 3; q = 3; r = 7; return;
                case EHoneycomb.H33I:
                    p = 3; q = 3; r = -1; return;
            }

            throw new System.ArgumentException();
        }
コード例 #12
0
ファイル: H3Supp.cs プロジェクト: roice3/Honeycombs
        private static void GetAssociatedTiling( EHoneycomb honeycomb, out Tiling tiling, out Tile baseTile )
        {
            int p, q;
            GetPQ( honeycomb, out p, out q );
            TilingConfig tilingConfig = new TilingConfig( p, q, maxTiles: m_params.MaxTiles );
            tiling = new Tiling();
            tiling.Generate( tilingConfig );

            baseTile = Tiling.CreateBaseTile( tilingConfig );
        }
コード例 #13
0
ファイル: H3Supp.cs プロジェクト: roice3/Honeycombs
        /// <summary>
        /// Our approach will be:
        /// (1) Generate a portion of one cell.
        /// (2) Reflect all facets in the central facet, to get things filled-in inside the central facet.  (Trim small edges here?)
        /// (3) Copy this region around the plane, and go back to step (2) if density is not high enough.
        /// (4) Map to Ball, trimming edges that become too small.
        /// NOTE: All verts are on the boundary, so we can reflect around 
        //          in circles on the plane at infinity, rather than spheres.
        /// </summary>
        public static void GenerateExotic( EHoneycomb honeycomb, H3.Settings settings )
        {
            settings.AngularThickness = 0.17;

            Tiling tiling;
            Tile baseTile;
            GetAssociatedTiling( honeycomb, out tiling, out baseTile );

            List<H3.Cell.Edge> edges = new List<H3.Cell.Edge>();
            foreach( Segment seg in baseTile.Boundary.Segments )
                edges.Add( new H3.Cell.Edge( seg.P1, seg.P2 ) );

            settings.Position = Polytope.Projection.FaceCentered;
            double scale = 1;
            Vector3D offset = new Vector3D();
            if( settings.Position == Polytope.Projection.FaceCentered )
            {
                scale = FaceCenteredScale( baseTile.VertexCircle );
                offset = new Vector3D();
            }
            else if( settings.Position == Polytope.Projection.EdgeCentered )
            {
                scale = EdgeCenteredScale( baseTile );
                offset = baseTile.Boundary.Segments[0].Midpoint;
            }

            int iterations = m_params.Iterations;
            for( int i=0; i<iterations; i++ )
                edges = DoOneStep( edges, tiling, baseTile.VertexCircle );
            edges = CopyAndProject( edges, tiling, scale, offset );

            if( m_params.RemoveDangling )
            {
                Dictionary<H3.Cell.Edge,int> edgeDict = edges.ToDictionary( e => e, e => 1 );
                H3.RemoveDanglingEdgesRecursive( edgeDict );
                edges = edgeDict.Keys.ToList();
            }

            string outputFileName = H3.m_baseDir + Honeycomb.String( honeycomb, false );
            System.IO.File.Delete( outputFileName );

            if( m_params.Output == H3.Output.STL )
            {
                outputFileName += ".stl";

                // Now mesh the edges.
                Shapeways mesh = new Shapeways();
                foreach( H3.Cell.Edge edge in edges )
                {
                    // Append to the file vs. writing out all at once because I was running out of memory otherwise.
                    mesh = new Shapeways();
                    int div;
                    H3Models.Ball.LODThin( edge.Start, edge.End, out div );
                    mesh.Div = div;
                    H3.Util.AddToMeshInternal( mesh, edge.Start, edge.End );
                    mesh.Mesh.Scale( settings.Scale );
                    STL.AppendMeshToSTL( mesh.Mesh, outputFileName );
                }
            }
            else
            {
                outputFileName += ".pov";
                PovRay.WriteH3Edges( new PovRay.Parameters()
                    {
                        AngularThickness = settings.AngularThickness,
                        Halfspace = settings.Halfspace,
                        ThinEdges = settings.ThinEdges,
                    },
                    edges.ToArray(), outputFileName );
            }
        }
コード例 #14
0
ファイル: H3Supp.cs プロジェクト: roice3/Honeycombs
 private static void GetPQ( EHoneycomb honeycomb, out int p, out int q )
 {
     int r;
     Honeycomb.PQR( honeycomb, out p, out q, out r );
 }
コード例 #15
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");
        }
コード例 #16
0
ファイル: H3Supp.cs プロジェクト: remuladgryta/MagicTile
        /// <summary>
        /// Our approach will be:
        /// (1) Generate a portion of one cell.
        /// (2) Reflect all facets in the central facet, to get things filled-in inside the central facet.  (Trim small edges here?)
        /// (3) Copy this region around the plane, and go back to step (2) if density is not high enough.
        /// (4) Map to Ball, trimming edges that become too small.
        /// NOTE: All verts are on the boundary, so we can reflect around
        //		  in circles on the plane at infinity, rather than spheres.
        /// </summary>
        public static void GenerateExotic(EHoneycomb honeycomb, H3.Settings settings)
        {
            settings.AngularThickness = 0.17;

            Tiling tiling;
            Tile   baseTile;

            GetAssociatedTiling(honeycomb, out tiling, out baseTile);

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

            foreach (Segment seg in baseTile.Boundary.Segments)
            {
                edges.Add(new H3.Cell.Edge(seg.P1, seg.P2));
            }

            settings.Position = Polytope.Projection.FaceCentered;
            double   scale  = 1;
            Vector3D offset = new Vector3D();

            if (settings.Position == Polytope.Projection.FaceCentered)
            {
                scale  = FaceCenteredScale(baseTile.VertexCircle);
                offset = new Vector3D();
            }
            else if (settings.Position == Polytope.Projection.EdgeCentered)
            {
                scale  = EdgeCenteredScale(baseTile);
                offset = baseTile.Boundary.Segments[0].Midpoint;
            }

            int iterations = m_params.Iterations;

            for (int i = 0; i < iterations; i++)
            {
                edges = DoOneStep(edges, tiling, baseTile.VertexCircle);
            }
            edges = CopyAndProject(edges, tiling, scale, offset);

            if (m_params.RemoveDangling)
            {
                Dictionary <H3.Cell.Edge, int> edgeDict = edges.ToDictionary(e => e, e => 1);
                H3.RemoveDanglingEdgesRecursive(edgeDict);
                edges = edgeDict.Keys.ToList();
            }

            string outputFileName = H3.m_baseDir + Honeycomb.String(honeycomb, false);

            System.IO.File.Delete(outputFileName);

            if (m_params.Output == H3.Output.STL)
            {
                outputFileName += ".stl";

                // Now mesh the edges.
                Shapeways mesh = new Shapeways();
                foreach (H3.Cell.Edge edge in edges)
                {
                    // Append to the file vs. writing out all at once because I was running out of memory otherwise.
                    mesh = new Shapeways();
                    int div;
                    H3Models.Ball.LODThin(edge.Start, edge.End, out div);
                    mesh.Div = div;
                    H3.Util.AddToMeshInternal(mesh, edge.Start, edge.End);
                    mesh.Mesh.Scale(settings.Scale);
                    STL.AppendMeshToSTL(mesh.Mesh, outputFileName);
                }
            }
            else
            {
                outputFileName += ".pov";
                PovRay.WriteH3Edges(new PovRay.Parameters()
                {
                    AngularThickness = settings.AngularThickness,
                    Halfspace        = settings.Halfspace,
                    ThinEdges        = settings.ThinEdges,
                },
                                    edges.ToArray(), outputFileName);
            }
        }
コード例 #17
0
ファイル: H3Supp.cs プロジェクト: roice3/Honeycombs
 public static bool IsExotic( EHoneycomb honeycomb )
 {
     return
         honeycomb == EHoneycomb.H444 ||
         honeycomb == EHoneycomb.H636 ||
         honeycomb == EHoneycomb.H363;
 }