TikZ PGF Diagrams Grids – How to Draw Triangular Grid in TikZ

diagramsgridstikz-pgf

Is there an easy way to draw a triangular grid in TikZ, like this?

Best Answer

Like Leo said: use \foreach and some math:

\usetikzlibrary{calc}

\newcommand*\rows{10}
\begin{tikzpicture}
    \foreach \row in {0, 1, ...,\rows} {
        \draw ($\row*(0.5, {0.5*sqrt(3)})$) -- ($(\rows,0)+\row*(-0.5, {0.5*sqrt(3)})$);
        \draw ($\row*(1, 0)$) -- ($(\rows/2,{\rows/2*sqrt(3)})+\row*(0.5,{-0.5*sqrt(3)})$);
        \draw ($\row*(1, 0)$) -- ($(0,0)+\row*(0.5,{0.5*sqrt(3)})$);
    }
\end{tikzpicture}