3

我开发了一个代码,它采用一组 3D 坐标,并执行三角测量以生成凸包/Delaunay。

这很顺利,使用德鲁奈三角剖分,我可以使用 tsearchn 测试点是否包含在给定的体积中。

现在我想取两个这样的 3D 体积,并测试它们是否相交。此外,我想知道体积 A 与体积 B 相交的百分比。

我认为我可以在其中一个体积内生成一个网格点,然后使用 tsearchn 将它们测试到另一个。但我想知道是否有人知道更方便的方法。或者有做类似分析的建议。

非常感谢!

编辑...示例代码

对于此示例代码,shapeA将 50% 与shapeB.
我在代码末尾包含了一个部分,显示了tsearchn
我知道我可以通过增加形状的点数并使用测试它们来解决我的问题tsearchn

% Establish shapes by coordinates
botA = [ 0 0 0 ; ...
   1 0 0;  ...
   1 1 0;  ...
   0 1 0 ];

topA = botA; topA(:,3) = 1; 
midA = [0.5 0.5 0.5];

botB = [ 0 0 0.5 ; ...
   1 0 0.5;  ...
   1 1 0.5;  ...
   0 1 0.5 ];

topB = botA; topB(:,3) = 1.5; 
midB = [0.5 0.5 1];

% Shape arrays
shapeA = [botA;midA;topA];
shapeB = [botB;midB;topB];

% Establish volume by using the delaunayn() function
dtA = delaunayn(shapeA);
dtB = delaunayn(shapeB);

% Plot the volume surfaces 
shapesurfA=tetramesh(dtA,shapeA);
set(shapesurfA,'FaceColor','b','FaceAlpha',.90,'EdgeAlpha',1);

hold on
shapesurfB=tetramesh(dtB,shapeB);
set(shapesurfB,'FaceColor','y','FaceAlpha',.90,'EdgeAlpha',1);
hold off
axis equal

%example of point in volume test
%if tsearchn output = NaN then testpoint is not in volume
testpoint1 = tsearchn(shapeA,dtA, [ 2 2 2]) % [test point [2 2 2] in volume A
testpoint2 = tsearchn(shapeA,dtA, [0.75 0.75 0.75])
4

0 回答 0