To make a convex rectangular 2d patch in 3d
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
darova
le 12 Fév 2020
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

1 commentaire
darova
le 12 Fév 2020
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]

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

Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Polygons dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!