通过三角网格的线MatLab

问题描述

我有一个三角网格(如图所示),我想找到穿过这些点的线(见图)。我尝试了 2D 拟合,但我失去了网格的形状。 有人可以建议一种方法来获得我用手淹死的线吗?

enter image description here

解决方法

在没有实际 3D 路径或网格的情况下,我模拟了一个并向您展示了如何使用 3D 样条进行插值:

% simulating a 3D path and plotting it
N = 1000;
rng(1);
xyz = cumsum([randn(N,1)+0.8,randn(N,1)+0.2,1)*2]);
plot3(xyz(:,1),xyz(:,2),3),'-b','LineWidth',2);
box on; view(30,30);

% interpolating using 3D splines.
% "smoothness" determines how many points to skip.
smoothness = floor( N/30 );
hold on;
fnplt(cscvn(xyz(1:smoothness:end,:)'),'r',2);
hold off;

结果显示如下(原始路径为蓝色,插值路径为红色): enter image description here