Adjacent connections and distance between adjacent point clouds
ttsesm opened this issue · 4 comments
Hi @marcomusy,
Is there any easy way to get the adjacency connection between neighboring point clouds based on their distance to each other. For example in the following point clouds:
I should get something like that:
which is related to whether two point clouds are neighbors which you can specify it as a threshold of the minimum distance between the two closest points of the two point clouds.
You can try this:
from vedo import *
tiles = load("data/pcds/pcd_*.ply")
# tiles = load("tile_*.ply")
dists = {}
for i, tile1 in enumerate(tiles):
tile1.subsample(0.02).write(f"tile_{i}.ply")
for j, tile2 in enumerate(tiles):
if i <= j:
continue
dist = np.min(tile1.distance_to(tile2))
dists[(i,j)] = dist
lines = []
for i, tile1 in enumerate(tiles):
tile1.color(i).alpha(0.25).point_size(5)
cm1 = tile1.center_of_mass()
for j, tile2 in enumerate(tiles):
if i <= j:
continue
if dists[(i,j)] < 10:
cm2 = tile2.center_of_mass()
line = Line(cm1, cm2).lw(4)
lines.append(line)
show(tiles, lines, axes=1)
Looks good... ❤️
One clarification though the dist = np.min(tile1.distance_to(tile2))
is computed from the center of the point clouds to each other or the it gets the distance between all points of pcd1 to all points pcd2 and keeps the minimum one based on which two points between teh two pcds are the nearest ones. Because from the description of the function is not clear... 🤔
Computes the distance from one point cloud or mesh to another point cloud or mesh.
This new `pointdata` array is saved with default name "Distance".
Keywords ``signed`` and ``invert`` are used to compute signed distance,
but the mesh in that case must have polygonal faces (not a simple point cloud),
and normals must also be computed.
It is the second case, right?
Yes - the second: all distances are computed irrespective of the center of mass.
Thanks a lot.
(It even found a connection that I have overlooked in the top four tiles 👍 )