Effacer les filtres
Effacer les filtres

Draw partial spheroid include a spheroid

6 vues (au cours des 30 derniers jours)
KOU DU
KOU DU le 29 Juil 2019
Commenté : Kim le 17 Oct 2019
I want to draw 1/8 spheroid include a small spheroid and output the geometry for mesh. But my current coding always have discontinue in the cutting plan.
Can anyone help provide a idea of cutting the spheroid in 1/8 not for showing but get the data.

Réponse acceptée

Bruno Luong
Bruno Luong le 21 Août 2019
Modifié(e) : Bruno Luong le 21 Août 2019
The code bellow us this FEX to generate mesh points.
% radius of the inner/outer spherical parts
r1 = 1;
r2 = 2;
n = 20; % discretization parameters of spherical parts
W = allVL1(3, n); % FEX file
% Connectivity
XY = W*[0 1 0;
0 0 1].';
F=delaunay(XY);
% Points in S2
Tri3 = eye(3);
W = W/n;
XYZ = W*Tri3';
XYZ = XYZ ./ sqrt(sum(XYZ.^2,2));
% inner/outer sphericals
XYZ1 = XYZ*r1;
XYZ2 = XYZ*r2;
% TRUE for points on the boundary
ibdr = W==0;
close all
patcharg = {'FaceColor', 'g', 'FaceAlpha', 0.5};
patch('Faces', F, 'Vertices', XYZ1, patcharg{:});
patch('Faces', F, 'Vertices', XYZ2, patcharg{:});
for k=1:3
XYZk = [XYZ1(ibdr(:,k),:); flipud(XYZ2(ibdr(:,k),:))];
% You are free to mesh XYZk, I leave it as polygonal shape (quarter of a rings)
patch('XData', XYZk(:,1), 'YData', XYZk(:,2), 'ZData', XYZk(:,3), patcharg{:});
end
view(3)
axis equal
  13 commentaires
KOU DU
KOU DU le 22 Août 2019
Thank you!
Kim
Kim le 17 Oct 2019
Since I have a similar problem, I tried to compile this programm but as in my case, I always get the error "Input argument must be a triangulation object."
Could anybody point out, what mistake I've been making?

Connectez-vous pour commenter.

Plus de réponses (2)

darova
darova le 19 Août 2019
Use patch() to generate planes
clc,clear
R = 10;
r = 3;
t = linspace(0,pi/2,20);
x = [r*cos(t) fliplr(R*cos(t))];
y = [r*sin(t) fliplr(R*sin(t))];
patch(x,y,x*0,'b')
hold on
patch(x,x*0,y,'b')
patch(x*0,x,y,'b')
hold off
alpha(0.5)
view(3)
  13 commentaires
KOU DU
KOU DU le 22 Août 2019
Thanks darova. Sorry I don't see the question of shapes. The inner shape is not only a ellispoid.
KOU DU
KOU DU le 22 Août 2019
And as you said. I try to introduce p but not success. Whatever, thank you very much.

Connectez-vous pour commenter.


Abhisek Pradhan
Abhisek Pradhan le 7 Août 2019
Following code may be used as an alternative to draw a sphere. Theta and Phi can be varied to get the desired result.
R=10;
Phi=linspace(-pi,pi);
Theta=linspace(0,2*pi);
[Phi,Theta]=meshgrid(Phi,Theta);
Z=R*sin(Phi);
X=R*cos(Phi).*cos(Theta);
Y=R*cos(Phi).*sin(Theta);
hSurface = surf(X,Y,Z);
set(hSurface,'FaceColor',[0 0 1], 'FaceAlpha',0.5,'FaceLighting','gouraud','EdgeColor','none');
Refer meshgrid and surf for more information.
  1 commentaire
KOU DU
KOU DU le 19 Août 2019
Thanks, Pradhan. But I know how to draw a whole sphere or other geometry. The problem I meet now is the discontinue in the cutting plan.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by