I am extremely new to Tikz, and know that it's easy to draw regular (Cartesian) grids, but haven't seen any examples using unstructured grids.
Is this possible to do in Tikz, and if so, is there a MWE available somewhere?
EDIT: From the comments below, to better clarify what I'm looking for:
To start, I would like a 2D case with a small mesh, say regularly spaced nodes (5×5) made into a Delaunay mesh. I would only need to display vertices and edges.
Eventually, I'd like to expand the example to 3D and overly semi-transparent block elements on this mesh, elements similar to the cone segment on the left of this example: texample.net/tikz/examples/3d-cone
My case would be a bit simpler since I'd just be using cubes. However, I just want to get the 2D mesh case figured out first, and expand from there.
EDIT2: Based on the answer below, I drew a grid with regular spacing using:
\documentclass[tikz,border=5]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \i [evaluate={\ii=int(\i-1);}] in {0,...,3}{
\foreach \j [evaluate={\jj=int(\j-1);}] in {0,...,3}{
\coordinate [shift={(\j,\i)}] (n-\i-\j) at (0:0);
\ifnum\i>0
\draw [help lines] (n-\i-\j) -- (n-\ii-\j);
\fi
\ifnum\j>0
\draw [help lines] (n-\i-\j) -- (n-\i-\jj);
\ifnum\i>0
\pgfmathparse{int(rnd>.5)}
\ifnum\pgfmathresult=0
\draw [help lines] (n-\i-\j) -- (n-\ii-\jj);
\else%
\draw [help lines] (n-\ii-\j) -- (n-\i-\jj);
\fi%
\fi
\fi
}}
\end{tikzpicture}
With the only issue that the way it connects the vertices is not always consistent.
Best Answer
Something like this?
And some triangles...
Although something like
asymptote
may be better for this kind of thing (see g.kov's answer), if you likepython
and usescipy
and are happy compiling with--shell-escape
the following (rather impractical) code may be a useful starting point.