geometry-central icon indicating copy to clipboard operation
geometry-central copied to clipboard

Vector operations on Vertices

Open cbw36 opened this issue 4 years ago • 2 comments

I am trying to do arithmetic on vertices, such as finding the distance between two vertices, but cannot find a method that is supported. geometrycentral::surface::Vertex does not seem to define vertex coordinates, nor are arithmetic operations defined. I also tried converting to geomectrycentral::Vector3, but that does not seem possible either. Is there a way to do this?

cbw36 avatar Mar 16 '21 17:03 cbw36

The Vertex objects in geometry-central are just logical handles, which represent an element in the mesh connectivity. The geometry is stored separately, for instance in the VertexPositionGeometry you get back when loading a mesh from file. We use this architecture to allow techniques like associating multiple sets of positions with a single mesh, or defining geometry by data other than vertex positions.

To get a vertex position, do something like

SurfaceMesh& mesh;
VertexPositionGeometry& geometry; // you probably have this from however you got the mesh

for(Vertex v : mesh.vertices()) {
  Vector3& pos = geometry.inputVertexPositions[v];
  // do stuff
}

nmwsharp avatar Mar 16 '21 20:03 nmwsharp

Thanks so much, this is very helpful. Is there a way to create the mesh from a shape_msgs::Mesh? Or does it have to be from a file?

cbw36 avatar Mar 17 '21 19:03 cbw36