How to extract intersection between two 3D shapes

46 次查看(过去 30 天)
I have a two 3D shapes, one defined by a patch object, the other by a simple analytical function (in my case a sphere):
[verts, faces, cindex] = teapotGeometry;
sphere_origin = [1 1 1];
sphere_radius = 1;
figure;
p = patch('Faces',faces,'Vertices',verts,'FaceVertexCData',cindex,'FaceColor','interp');
sph = drawSphere([sphere_origin sphere_radius]); % using matGeom (https://github.com/mattools/matGeom)
I'd like a way to slice the patch into 2 or more sub-objects that contains the part of the teapot outside the sphere, and the one that is inside.
My main problems are that I don't know:
  1. How to find the exact intersection between the sphere and the 3D shape (not just the closest vertice, but the extrapolated one). (DONE: using surfaceintersection as @darova suggested)
  2. How to add the faces to the extrapolated vertices in a way that conserve the integrity of the teapot if i were to plot only the sub-objects found.
I suppose the right way to start is to find the faces that are intersecting the sphere like this:
out_pnt = find(vecnorm(verts-sphere_origin,2,2)>=sphere_radius);
out_faces = any(ismember(faces,out_pnt),2);
But going from there to finding the exact set of points that define the intersection is really difficult for me right now.
Any part of the answer could really help me, thanks in advance.
  10 个评论
hagege ruben
hagege ruben 2020-7-12
This seems like the function I need, too bad it's not available...
Joseph Olson
Joseph Olson 2022-2-21
Seems like the inShape function is what you want!
https://www.mathworks.com/matlabcentral/answers/496500-intersection-volume-of-two-3d-alphashapes

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by