public Tile[] FundamentalCell() { Tile template = TemplateTile(); Tile.ShrinkTile(ref template, 0.9); // Generate a cell tiling. TilingConfig tilingConfig = new TilingConfig(Q, P); Tiling poly = new Tiling(); poly.Generate(tilingConfig); m_tiles = poly.Tiles.ToList(); //SetupTransformCircle( tile ); // Call this before transforming. //SetupNeighborCircle( tile ); // Generate our cell. List <Tile> cellTiles = new List <Tile>(); foreach (Tile t in poly.Tiles) { Tile temp = template.Clone(); temp.Transform(t.Isometry.Inverse()); cellTiles.Add(temp); } return(cellTiles.ToArray()); }
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); }
public void GenerateInternal(TilingConfig config, Polytope.Projection projection = Polytope.Projection.FaceCentered) { this.TilingConfig = config; // Create a base tile. Tile tile = CreateBaseTile(config); // Handle edge/vertex centered projections. if (projection == Polytope.Projection.VertexCentered) { Mobius mobius = config.VertexCenteredMobius(); tile.Transform(mobius); } else if (projection == Polytope.Projection.EdgeCentered) { Mobius mobius = config.EdgeMobius(); tile.Transform(mobius); } TransformAndAdd(tile); List <Tile> tiles = new List <Tile>(); tiles.Add(tile); Dictionary <Vector3D, bool> completed = new Dictionary <Vector3D, bool>(); completed[tile.Boundary.Center] = true; ReflectRecursive(tiles, completed); FillOutIsometries(tile, m_tiles, config.Geometry); FillOutIncidences(); }
public static Tile CreateBaseTile(TilingConfig config) { Polygon boundary = new Polygon(), drawn = new Polygon(); boundary.CreateRegular(config.P, config.Q); drawn = boundary.Clone(); //boundary.CreateRegular( 3, 10 ); //drawn.CreateRegular( 3, 8 ); //boundary.CreateRegular( 3, 7 ); //drawn = Heart(); //for( int i=0; i<drawn.NumSides; i++ ) // drawn.Segments[i].Center *= 0.1; // Good combos: // ( 5, 5 ), ( 10, 10 ) // ( 3, 10 ), ( 3, 9 ) // ( 6, 4 ), ( 6, 8 ) // ( 7, 3 ), ( 7, 9 ) Tile tile = new Tile(boundary, drawn, config.Geometry); Tile.ShrinkTile(ref tile, config.Shrink); return(tile); }
/// <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; }
private static Segment[] BaseTileSegments(int p, int q) { Tiling tiling = new Tiling(); TilingConfig config = new TilingConfig(p, q, 1); Tile baseTile = Tiling.CreateBaseTile(config); //baseTile.Transform( Mobius.Scale( 2 ) ); // Only works in Euclidean case return(baseTile.Boundary.Segments.ToArray()); }
private void Transform(double anim, IEnumerable <Tile> tetTiles) { //TilingConfig config = new TilingConfig( 8, 3, 4 ); // Reproduces Tolerance issues with {3,3,7}, though not actually correct to be applying hyperbolic transforms anyway (only spherical). TilingConfig config = new TilingConfig(3, 3, 1); Mobius m = new Mobius(); m = Mobius.Identity(); // Invert Complex c1 = new Complex(0, 1); Complex c2 = new Complex(1, 0); Complex c3 = new Complex(0, -0.999999999999); // - 1 doesn't work //m.MapPoints( c1, c2, c3, c3, c2, c1 ); //Mobius m = config.DualMobius(); //m.Isometry( Geometry.Spherical, 0, new Complex( 1.2345, -0.4321 ) ); // nice one //m.Isometry( Geometry.Spherical, 0, new Complex( 0, 0.148125 ) ); // half plane // Animation. double p2 = DonHatch.e2hNorm(0.6); double p2Interp = DonHatch.h2eNorm(p2 * anim); //m.Isometry( Geometry.Spherical, 0, -p2Interp ); m.Isometry(Geometry.Hyperbolic, 0, new Complex(-p2Interp, 0)); Mobius m2 = new Mobius(); m2.Isometry(Geometry.Hyperbolic, 0, new Complex(-0.6, 0)); m2 = m_fixedCircleToStandardDisk.Inverse() * m2 * m_fixedCircleToStandardDisk; bool firstAnim = false; if (firstAnim) { m = m_fixedCircleToStandardDisk.Inverse() * m * m_fixedCircleToStandardDisk; m_animMobius = m; } else { m = m_neighborToStandardDisk.Inverse() * m * m_neighborToStandardDisk; m_animMobius = m2 * m; } m_animMobius.Normalize(); foreach (Tile t in tetTiles) { t.Transform(m_animMobius); } foreach (Tile t in m_tiles) { t.Transform(m_animMobius); } m_equator.Transform(m_animMobius); m_neighborCircle.Transform(m_animMobius); }
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); }
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" ); }
/// <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 ); */ }
/// <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); }
/// <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); }
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; }
/// <summary> /// Generate ourselves from a tiling config. /// </summary> public void Generate(TilingConfig config) { GenerateInternal(config); }
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 ); }
public static Tile CreateBaseTile( TilingConfig config ) { Polygon boundary = new Polygon(), drawn = new Polygon(); boundary.CreateRegular( config.P, config.Q ); drawn = boundary.Clone(); //boundary.CreateRegular( 3, 10 ); //drawn.CreateRegular( 3, 8 ); //boundary.CreateRegular( 3, 7 ); //drawn = Heart(); //for( int i=0; i<drawn.NumSides; i++ ) // drawn.Segments[i].Center *= 0.1; // Good combos: // ( 5, 5 ), ( 10, 10 ) // ( 3, 10 ), ( 3, 9 ) // ( 6, 4 ), ( 6, 8 ) // ( 7, 3 ), ( 7, 9 ) Tile tile = new Tile( boundary, drawn, config.Geometry ); Tile.ShrinkTile( ref tile, config.Shrink ); return tile; }
private static void HyperidealSquares() { Mobius rot = new Mobius(); rot.Isometry( Geometry.Spherical, Math.PI / 4, new Vector3D() ); List<Segment> segs = new List<Segment>(); int[] qs = new int[] { 5, -1 }; foreach( int q in qs ) { TilingConfig config = new TilingConfig( 4, q, 1 ); Tile t = Tiling.CreateBaseTile( config ); List<Segment> polySegs = t.Boundary.Segments; polySegs = polySegs.Select( s => { s.Transform( rot ); return s; } ).ToList(); segs.AddRange( polySegs ); } Vector3D v1 = new Vector3D(1,0); v1.RotateXY( Math.PI/6 ); Vector3D v2 = v1; v2.Y *= -1; Vector3D cen; double rad; H3Models.Ball.OrthogonalCircle( v1, v2, out cen, out rad ); Segment seg = Segment.Arc( v1, v2, cen, false ); rot.Isometry( Geometry.Spherical, Math.PI / 2, new Vector3D() ); for( int i = 0; i < 4; i++ ) { seg.Transform( rot ); segs.Add( seg.Clone() ); } SVG.WriteSegments( "output1.svg", segs ); System.Func<Segment, Segment> PoincareToKlein = s => { return Segment.Line( HyperbolicModels.PoincareToKlein( s.P1 ), HyperbolicModels.PoincareToKlein( s.P2 ) ); }; segs = segs.Select( s => PoincareToKlein( s ) ).ToList(); Vector3D v0 = new Vector3D( v1.X, v1.X ); Vector3D v3 = v0; v3.Y *= -1; Segment seg1 = Segment.Line( v0, v1 ), seg2 = Segment.Line( v2, v3 ); Segment seg3 = Segment.Line( new Vector3D( 1, 1 ), new Vector3D( 1, -1 ) ); for( int i = 0; i < 4; i++ ) { seg1.Transform( rot ); seg2.Transform( rot ); seg3.Transform( rot ); segs.Add( seg1.Clone() ); segs.Add( seg2.Clone() ); segs.Add( seg3.Clone() ); } SVG.WriteSegments( "output2.svg", segs ); }
/// <summary> /// Generate ourselves from a tiling config. /// </summary> public void Generate( TilingConfig config ) { GenerateInternal( config ); }
/// <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 ); */ }
public void GenerateInternal( TilingConfig config, Polytope.Projection projection = Polytope.Projection.FaceCentered ) { this.TilingConfig = config; // Create a base tile. Tile tile = CreateBaseTile( config ); // Handle edge/vertex centered projections. if( projection == Polytope.Projection.VertexCentered ) { Mobius mobius = config.VertexCenteredMobius(); tile.Transform( mobius ); } else if( projection == Polytope.Projection.EdgeCentered ) { Mobius mobius = config.EdgeMobius(); tile.Transform( mobius ); } TransformAndAdd( tile ); List<Tile> tiles = new List<Tile>(); tiles.Add( tile ); Dictionary<Vector3D,bool> completed = new Dictionary<Vector3D,bool>(); completed[tile.Boundary.Center] = true; ReflectRecursive( tiles, completed ); FillOutIsometries( tile, m_tiles, config.Geometry ); FillOutIncidences(); }
// 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 } ) ); } } }
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"); }
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 ) ); } }
private static Segment[] BaseTileSegments( int p, int q ) { Tiling tiling = new Tiling(); TilingConfig config = new TilingConfig( p, q, 1 ); Tile baseTile = Tiling.CreateBaseTile( config ); //baseTile.Transform( Mobius.Scale( 2 ) ); // Only works in Euclidean case return baseTile.Boundary.Segments.ToArray(); }