Find shortest path in 3d point cloud

Matlab has built in shortestpath function based on Dijkstra algorithm:

However the algorithm only applies to graph, We need to convert 3d point cloud to graph first in order to use it.

What constitutes a graph:

  • nodes (points or vertex)
  • edges (connectivity)

In matlab graph, connection is expressed as adjacency matrix, 

1. create adjacent matrix

d = pdist(PointsSet);
d_adj = squareform(d);

2. create graph and add in nodes

G = graph(d_adj) ;
G.Nodes = array2table(Position,'VariableNames',{'X','Y','Z'});

1. Random graph 

% https://www.mathworks.com/matlabcentral/answers/445321-how-to-find-shortest-distance-in-3d
% for repeatability 
rng('default')
% Generate 10 random 3d points
Position = 10*rand(10,3);
%Calculate pa
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值