To make a convex rectangular 2d patch in 3d

조회 수: 25 (최근 30일)
zilorina
zilorina 2020년 2월 11일
댓글: darova 2020년 2월 12일
I have several patch objects (please see the attached figure).
Is there some function that will deliver a rectangular convex shape of yellow and orange patches? Also, some function to fill the holes in the grey patch object?
I need only surfaces, so I do not think that alpha shape is a good choice.
  댓글 수: 2
darova
darova 2020년 2월 11일
Please attach the data
zilorina
zilorina 2020년 2월 11일
I have attached mat files for three isosurfaces (grey, yellow, and orange). For yellow and orange, I am trying to get a rectangular convex shape. For the grey one, just fill in the holes.
Surfaces can be visualuized in a following way:
load('isosurface.mat', 'X','Y','Z','W','level');
p = patch(isosurface(X, Y, Z, W, level));
and
load('isosurface_yellow.mat', 'xq','yq','zq','vq','level');
p = patch(isosurface(xq, yq, zq, vq, level));

댓글을 달려면 로그인하십시오.

채택된 답변

darova
darova 2020년 2월 12일
I tried griddata. Can't figure out why doesn't it work
clc,clear,cla
load('isosurface_orange.mat');
[f,v] = isosurface(xq, yq, zq, vq, level); % extract data
xdata = v(:,1)-max(v(:,1)); % move to origin
ydata = v(:,2)-max(v(:,2))-0.1;
[th,rho] = cart2pol(xdata,ydata); % convert to polar/cylindrical system
th0 = linspace(min(th),max(th),100);
z0 = linspace(min(v(:,3)),max(v(:,3)),100);
[TH0,Z0] = meshgrid(th0,z0);
RHO0 = griddata(th,v(:,3),rho,TH0,Z0); % interpolation
% [X0,Y0] = pol2cart(TH0,RHO0);
% patch('faces',f,'vertices',v,'facecolor','g')
plot3(th*180/pi,v(:,3),rho,'.r')
hold on
surf(TH0*180/pi,Z0,RHO0,'facecolor','b','edgecolor','none')
% surf(X0+max(v(:,1))-30*0,Y0+max(v(:,2))-30*0,Z0,'facecolor','b')
hold off
camlight('headlight');
material('dull');
axis equal
img1.png
  댓글 수: 1
darova
darova 2020년 2월 12일
I tried to convert radians to degrees before interpolation
I also mirrored data so that in cylindrical system angle is in [-pi/2 .. pi/2]
img2.png
load('isosurface.mat')
[f,v] = isosurface(X, Y, Z, W, level);
xdata = -v(:,1)+max(v(:,1))-0.1; % mirror and move to origin
ydata = v(:,2)-max(v(:,2))/2-0.1; % move to origin/center
[th,rho] = cart2pol(xdata,ydata);
th = rad2deg(th); % convert to degrees
th0 = linspace(min(th),max(th),50);
z0 = linspace(min(v(:,3)),max(v(:,3)),20);
[TH0,Z0] = meshgrid(th0,z0);
RHO0 = griddata(th,v(:,3),rho,TH0,Z0);
TH0 = deg2rad(TH0);
[X0,Y0] = pol2cart(TH0,RHO0);
patch('faces',f,'vertices',v,'facecolor','g','edgecolor','none')
hold on
surf(-X0+max(v(:,1)),Y0+max(v(:,2))/2,Z0,'facecolor','none')
hold off
camlight('headlight');
material('dull');
axis equal
The result
img1.png

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polygons에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by