# The following mesh/grid like diagram in tikz

I need to create a picture as shown in the attachment. I know how to create the hexagonal substructure and the code for the same can be found in this question: Hyperbolic polyhedron in tikz

Edit: The function which maps the subdivided icosahedron to the plane behaves like $z^{6/5}$ at the vertex of degree 5 (hereby denoted by $v$).

• Show us the origin of the picture. We might be able to find useful parametrization therein. Apr 15, 2019 at 20:20
• Basically, I am subdividing an icosahedron and mapping it using a conformal map (except at the 12 vertices of degree 5) to the plane. So in this image, there is one vertex of degree 5 and the others are of degree 6. Apr 15, 2019 at 20:22
• You might use nonlinear transformations to achieve this but should not expect us to extract the conformal map from the picture.
– user121799
Apr 15, 2019 at 20:47
• The conformal map is not described explicitly. Its behavior is known (it distorts the triangles near the vertex of degree 5 and as we move further the triangles are nearly equilateral). What kind of nonlinear transformations should I use? Could you please elaborate, @marmot? Apr 15, 2019 at 21:09
• A TiKz based package luamesh can be help you: ctan.org/pkg/luamesh
– user31034
Apr 15, 2019 at 21:24

You can draw such grids with \foreach loops.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes.geometric,calc}
\begin{document}
\begin{tikzpicture}[web/.style={append after command={foreach \XX in {1,...,#1}
{(current.corner \XX)
-- (current.center)}},regular polygon,regular polygon sides=#1,minimum
size=1cm,draw,alias=current},
pics/outerior/.style={code={
\pgfmathtruncatemacro{\idiv}{pow(2,#1-1)}
\draw (90:#1*0.5) foreach \XX in {1,...,5}
{-- (90+72*\XX:#1*0.5) coordinate (P-\XX)};
\draw (90:#1*0.5+0.5) foreach \XX in {1,...,5}
{-- coordinate[midway] (M-\XX) (90+72*\XX:#1*0.5+0.5) coordinate (Q-\XX)};
\foreach \XX [remember=\XX as \YY (initially 5)] in {1,...,5}
{\draw (P-\XX) -- (Q-\XX);
\foreach \ZZ in {0,...,#1}
{\draw ($(Q-\XX)!{(\ZZ+1)/(#1+1)}!(Q-\YY)$) -- ($(P-\XX)!{\ZZ/#1}!(P-\YY)$) --
($(Q-\XX)!{\ZZ/(#1+1)}!(Q-\YY)$) ;}
}
}}]
\draw (0,0) node[web=5] (c5) {};
\clip (-3,-3) rectangle (3,3);
\draw foreach \X in {1,...,9} {(0,0) pic{outerior=\X}};
\end{tikzpicture}
\end{document}


P.S. Your prescription does not seem to yield the drawn lattice when using regular polygons (and also to introduce polygons that automatically have the internal lines added via append after command.

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes.geometric,calc}
\begin{document}
\begin{tikzpicture}[web/.style={append after command={foreach \XX in {1,...,#1}
{(current.corner \XX)
-- (current.center)}},regular polygon,regular polygon sides=#1,minimum
size=1cm,draw,alias=current}]
\draw (0,0) node[web=5] (c5) {};
\foreach \X [remember=\X as \Y (initially 5)] in {1,...,5}
{\draw
let \p1=($(c5.corner \Y)-(c5.corner \X)$),\n1={atan2(\y1,\x1)}
in ($(c5.corner \Y)!0.5!(c5.corner \X)$) coordinate (aux)
($(aux)!{-(1/2)*1cm}!90:(c5.corner \X)$)
node[web=6,minimum size=6cm/5,rotate=\n1]{};}
\end{tikzpicture}
\end{document}


• Just a comment: OP's picture seems to be an unstructured mesh, generated by some meshing algorithm. These algorithms mostly work from the outlines of the domain towards the middle, so some geometry (which is not shown in the picture) caused the algorithm to converge to a pentagon in that spot. But generally no triangles are equilateral in these meshes, so I think OP's request is rather unpractical :/ Apr 15, 2019 at 22:25
• @PhelypeOleinik Yes. I still think one can use nonlinear transformations to get that grid but not the OP's prescription.
– user121799
Apr 15, 2019 at 22:29
• @marmot The picture that you generated is "very nice" (in the sense that it has only linear components). The problem is that I need the triangles near the vertex of degree 5 to be small and distorted whereas as we go further they should be nearly equilateral. Can this effect be created? Apr 16, 2019 at 5:23

This mesh structure is generated with Delaunay triangulation method. You know that this method is quite complicated. The luamesh package wrote by Maxime Chupin is a great work for using Delaunay triangulation in TeX/LaTeX.

The TiKz based package luamesh can be downloaded from here. In the web site page, click download link as seen following picture.

Extract the zip file in a directory. You will see a directory named scripts. The files in this directory are required lua scripts for the package. Write a code like following and save it in scripts directory.

\documentclass[margin=3.1415mm]{standalone}
\usepackage{luamesh}

\begin{document}

\meshPolygon[
tikz,
color = blue!70,
%meshpoint = \alpha,
colorPolygon=black,
scale=4cm,
step=mesh,
% print=points,
gridpoints=perturb
]
{(0,0);(1,0);(1,1);(0,1)}

\end{document}


Now compile this file with LuaLaTeX. The result is as follows.

ADDENDUM: You can adjust the mesh density with h value. The mesh parameter, it is the unit distance for the grid. If necessary, the boundary is refined to get points which respect the distance constrain. Default value is 0.2. Add the h parameter to \meshPolygon environment, like:

\meshPolygon[
tikz,
color = blue!70,
%meshpoint = \alpha,
colorPolygon=black,
scale=4cm,
step=mesh,
% print=points,
gridpoints=perturb,
h=0.1
]
{(0,0);(1,0);(1,1);(0,1)}


An the result:

• luamesh is in both TeX Live and MikTeX. There should be virtually no need to download manually. Apr 16, 2019 at 0:22
• @HenriMenke, you are right. But the contributors say in luamesh-doc.pdf at page 4, "As these two systems are unknown to the contributor, we refer to the documentation for integrating local additions to MikTEX: docs.miktex.org/manual/localadditions.html". This is for the how to using the .lua files. I pointed out a simple way.
– user31034
Apr 16, 2019 at 0:47
• Besides, I didn't say to install the package.
– user31034
Apr 16, 2019 at 0:55
• I pasted your example and typeset successfully with LuaLaTeX without having to download and extract anything. It might be unnecessary. Apr 16, 2019 at 1:33