Mesh plot

edgmesh

template<typename T>
inline void castor::edgmesh(figure &fig, matrix<std::size_t> const &edg, matrix<T> const &vtx, matrix<T> const &val = {})

Displays a set of edges colored using vertex values.

The edges must be given in a mesh-like format where vtx is the list of all the nodes which must be displayed and edg is the list of the elements. The color on the edges is obtained by setting val which must contain a list of vertex-values.

mesh

template<typename T>
inline void castor::mesh(figure &fig, matrix<T> const &X, matrix<T> const &Y, matrix<T> const &Z, std::string const &options = "")

Displays a surface Z = f(X,Y) using scaled colors.

matrix<> X,Y;
std::tie(X,Y) = meshgrid(linspace(-M_PI,M_PI,100));
auto Z = 2*sin(X)/X * sin(Y)/Y;
figure fig;
mesh(fig,X,Y,Z);
drawnow(fig);

quiver

template<typename T>
inline void castor::quiver(figure &fig, matrix<T> const &vtx, matrix<T> const &dir, matrix<T> const &val = {})

Plots a set of vectors.

The vectors are defined by their origin vtx and their direction dir.

matrix<> vtx({{0.,0.,0.},{0.,1.,0.}});
matrix<> dir({{1.,1.,1.},{-0.2,1.,3.}});

figure fig;
quiver(fig,vtx,dir);
drawnow(fig);

tetmesh

template<typename T>
inline void castor::tetmesh(figure &fig, matrix<std::size_t> const &tet, matrix<T> const &vtx, matrix<T> const &val = {})

Plots a tetrahedral mesh colored with vertex values.

matrix<> X({0.,1,0,0}), Y({0.,0,1,0}), Z({0,0,0,1});
matrix<> vtx;
matrix<std::size_t> elt;
// Delaunay triangulation
std::tie(elt,vtx) = tetdelaunay(X,Y,Z);

figure fig;
tetmesh(fig,elt,vtx);
drawnow(fig);

trimesh

template<typename T>
inline void castor::trimesh(figure &fig, matrix<std::size_t> const &tri, matrix<T> const &vtx, matrix<T> const &val = {})

Plots a triangular mesh colored using vertex values.

vermesh

template<typename T>
inline void castor::vermesh(figure &fig, matrix<std::size_t> const &ver, matrix<T> const &vtx, matrix<T> const &val = {})

Plots colored vertices using vertex values.

matrix<std::size_t> elt = range(0,100);
matrix<> vtx = -1+2*rand(numel(elt),3);
figure fig;
vermesh(fig,elt,vtx,eval(vtx(row(vtx),0)));
drawnow(fig);