# Distance Quantities

Visualize distance-valued data at the elements of a surface mesh.

Distance quantities are basicly scalars, but are visualized with alternating stripes to show distance contours.

Example: visualizing exact geodesic distance computed via libIGL’s wrappers around Kirsanov’s MMP implementation.

// Compute distance from vertex iVertexSource
Eigen::VectorXi VS, FS, VT, FT;
VS.resize(1);
VS << iVertexSource;
VT.setLinSpaced(meshV.rows(), 0, meshV.rows() - 1);
Eigen::VectorXd d;
igl::exact_geodesic(meshV, meshF, VS, FS, VT, FT, d);

// Add the distance quantity to the surface mesh
polyscope::getSurfaceMesh("input mesh")
"distance from vertex " + std::to_string(iVertexSource), d);


SurfaceMesh::addVertexDistanceQuantity(std::string name, const T& values)
• values is the array of distances at vertices. The type should be adaptable to a float scalar array. The length should be the number of vertices in the mesh.
SurfaceMesh::addVertexDistanceQuantity(std::string name, const T& values)
• values is the array of distances at vertices. The type should be adaptable to a float scalar array. The length should be the number of vertices in the mesh.
This quantity is very similar to addVertexDistanceQuantity, except the colormap is adjusted to scale symetrically for negative values.