Beispiel #1
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 } ) );
                }
            }
        }
Beispiel #2
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));
                }
            }
        }