To make a convex rectangular 2d patch in 3d

24 visualizzazioni (ultimi 30 giorni)
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 Commenti
darova
darova il 11 Feb 2020
Please attach the data
zilorina
zilorina il 11 Feb 2020
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));

Accedi per commentare.

Risposta accettata

darova
darova il 12 Feb 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
img1.png
  1 Commento
darova
darova il 12 Feb 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]
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

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by