Scope interpretation in Matlab
I have developed a code that takes a set of 3D coordinates and triangulates to generate a convex hull / Delaunay.
This went well and with Deluanay triangulation I can check if points are contained in a given volume using tsearchn.
Now I want to take two such 3D volumes and check if they overlap. Moreover, I would like to know what percentage of volume A is crossed by volume B.
I think I could create a gridded grid of dots that are in one of the volumes and then check them against the other using tsearchn. But I wanted to know if anyone knows a more convenient way. Or do you have recommendations for similar analyzes.
Many thanks!
EDIT ... Code example
For this example code, there shapeA
will be 50% overlap with shapeB
.
I have included a section at the end of the code that shows usability tsearchn
I know I could solve my problem by increasing the number of points for the shapes and testing them withtsearchn
% 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])
source to share
No one has answered this question yet
See similar questions:
or similar: