Skip to content

Vector Quantities

Visualize vector-valued data at the nodes or edges of a curve network.

Example: add vectors at nodes

#include "polyscope/curve_network.h"

// Generate random vectors as example vector data
std::vector<glm::vec3> randVec(nNodes);
for (size_t iN = 0; iN < nNodes; iN++) {
  randVec[iN] = glm::vec3{polyscope::randomUnit() - .5, polyscope::randomUnit() - .5, polyscope::randomUnit() - .5};
}

// Add the vector data to the curve network
polyscope::getCurveNetwork("my curve")->addNodeVectorQuantity("sample vectors", randVec);

// Visualize
polyscope::show();

CurveNetwork::addNodeVectorQuantity(std::string name, const T& vectors, VectorType vectorType = VectorType::STANDARD)

Add a vector quantity to the nodes of a curve network. Vectors will be drawn with their roots at each edge.

  • vectors is the array of vectors at nodes. The type should be adaptable to a 3-vector array of floats. The length should be the number of nodes in the curve network.
  • vectorType indicates how to interpret vector data. The default setting is as a freely-scaled value, which will be automatically scaled to be visible. Passing VectorType::AMBIENT ensures vectors have the proper world-space length.

Note: the inner vector type of the input must be 3D dimensional, or you risk compiler errors, segfaults, or worse. If you want to add 2D vectors (usually to a 2D curve network), addNodeVectorQuantity2D exists with the same signature. See 2D data.

CurveNetwork::addEdgeVectorQuantity(std::string name, const T& vectors, VectorType vectorType = VectorType::STANDARD)

Add a vector quantity to the edges of a curve network. Vectors will be drawn with their roots at the center of each each.

  • vectors is the array of vectors at edges. The type should be adaptable to a 3-vector array of floats. The length should be the number of edges in the curve network.
  • vectorType indicates how to interpret vector data. The default setting is as a freely-scaled value, which will be automatically scaled to be visible. Passing VectorType::AMBIENT ensures vectors have the proper world-space length.

Note: the inner vector type of the input must be 3D dimensional, or you risk compiler errors, segfaults, or worse. If you want to add 2D vectors (usually to a 2D curve network), addEdgeVectorQuantity2D exists with the same signature. See 2D data.

Vector Quantity Options

These options and behaviors are available for all types of vector quantities on any structure.

Parameter Meaning Getter Setter Persistent?
enabled is the quantity enabled? bool isEnabled() setEnabled(bool newVal) yes
vector radius the radius vectors are drawn with double getVectorRadius() setVectorRadius(double val, bool isRelative=true) yes
vector length vectors will be scaled so the longest is this long. ignored if VectorType::Ambient double getVectorLengthScale() setVectorLengthScale(double val, bool isRelative=true) yes
vector color the color to draw the vectors with glm::vec3 getVectorColor() setVectorColor(glm::vec3 val) yes
material what material to use std::string getMaterial() setMaterial(std::string name) yes

(all setters return this to support chaining. setEnabled() returns generic quantity, so chain it last)