I have a given 3D surface plot My problem is drawing an area, f and cutting out exactly this area from the given plot.Please help!

3 件のコメント

darova
darova 2020 年 4 月 12 日
Show your data. Show your code. Open yourself up for us!
Jerry
Jerry 2020 年 4 月 13 日
i have a random 3d surface plot like in the picture, and programmed a triangle into the plot.
how do I substract exactly this shape of the triangle(in pink) from my given plot, so that there is a triangle area of the plot cut out?
Rena Berman
Rena Berman 2020 年 10 月 12 日
(Answers Dev) Restored edit

サインインしてコメントする。

 採用された回答

darova
darova 2020 年 4 月 13 日

1 投票

What about this?
clc,clear
% generate surface
r = 0:0.1:5;
t = linspace(0,2*pi,30);
[T,R] = meshgrid(t,r);
Z = 5*sin(R)./R;
[X,Y] = pol2cart(T,R);
% data for cutting
x = [1 3 0.7];
y = [0.2 0.3 3];
z = [1 1.2 1];
ix = convhull(X(:),Y(:)); % boundary of surface
x1 = X(ix(1:end-2)); % vertices of boundary
y1 = Y(ix(1:end-2));
gd1 = [2; length(x1); x1(:); y1(:)]; % surface boundary geometry
gd2 = gd1;
gd2(1:2+2*length(x)) = [2; length(x); x(:); y(:)]; % cutting plane boundary geometry
dl = decsg([gd1 gd2],'P1-P2',char('P1','P2')'); % decomposite geometry
[p,e,t] = initmesh(dl,'hmax',0.5); % create mesh
F = scatteredInterpolant(X(:),Y(:),Z(:));
zz = F(p(1,:),p(2,:)); % calculate Z coordinate for each mesh point
fv.vertices = [p;zz]'; % x y z data
fv.faces = t(1:3,:)'; % connection list of faces
cla
patch(fv,'facecolor','r') % surface
patch(x,y,z,'g') % cutting plane
view(150,45)
axis vis3d
If you have boundary intstead of convhull
ix = convhull(X(:),Y(:)); % boundary of surface

9 件のコメント

Jerry
Jerry 2020 年 4 月 14 日
thank you, but i have had a random surface sent to me and I dont even have the function for the surface. up there I just postet an example. so what do i do if i don't have information according to the given surface, just the geometrical position of all the points in the mesh?
darova
darova 2020 年 4 月 14 日
You don't need mesh. Try only points
Jerry
Jerry 2020 年 4 月 14 日
it doesn't work, maybe it has something to do with the fact that my given plot is an SGplot with a large Vertex and Facet list
darova
darova 2020 年 4 月 14 日
Can you attach the data?
Jerry
Jerry 2020 年 4 月 16 日
please help
darova
darova 2020 年 4 月 16 日
Can you attach the data for the picture?
Jerry
Jerry 2020 年 4 月 16 日
here's the picutre
darova
darova 2020 年 4 月 16 日
I choosed XZ plane to detect if points inside triangle (i used inpolygon)
Since there are another vertices inside i added Y axis condition:
where y1 - triangle verices, y2 - surface vertices
Result
Was not that easy! See attached script
Jerry
Jerry 2020 年 4 月 17 日
thank you so much! it is perfec!!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2020 年 4 月 12 日

コメント済み:

2020 年 10 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by