[英]Linking Vertex ID to coordinates in PyMeshLab
I am looking to be able able to link the Vertex ID with the coordinate positions.我希望能够将顶点 ID 与坐标位置联系起来。
Using m.edge_matrix
I can generate the list of vertex IDs for the edges that form a polyline.使用m.edge_matrix
我可以为形成折线的边生成顶点 ID 列表。 What is the easiest way to link this back to the actual coordinates?将其链接回实际坐标的最简单方法是什么?
Using m.vertex_matrix
produces the list of coordinates, but has no reference to the Vertex ID.使用m.vertex_matrix
生成坐标列表,但不引用顶点 ID。 The order in which the coordinates are listed in m.vertex_matrix
doesn't appear to link to the order in which they appear in m.edge_matrix
坐标在m.vertex_matrix
中列出的顺序似乎与它们在m.edge_matrix
出现的顺序m.edge_matrix
Many thanks.非常感谢。
The matrix returned by m.vertex_matrix()
is indexable . m.vertex_matrix()
返回的矩阵是indexable 。 The row n corresponds to coordinates of vertex with id=n, so you just need to use [ ] to read the row.第 n 行对应于 id=n 的顶点坐标,因此您只需要使用 [ ] 来读取该行。
v = m.vertex_matrix()
for e in m.edge_matrix():
print("edge", e, "goes from", v[e[0]], "to", v[e[1]])
which produces this output:产生这个输出:
edge [0 1] goes from [0.12843863 0.38690682 0.1] to [0.13383933 0.3839188 0.1]
edge [2 3] goes from [0.14307424 0.38100217 0.1] to [0.13592989 0.38318165 0.1]
edge [3 1] goes from [0.13592989 0.38318165 0.1] to [0.13383933 0.3839188 0.1]
edge [4 5] goes from [0.25161905 0.21663008 0.1] to [0.2520413 0.21464215 0.1]
edge [6 5] goes from [0.25537567 0.20097797 0.1] to [0.2520413 0.21464215 0.1]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.