Slt.
J'arrive pas a dessiner une sphère sur matlab,
Tu peux utiliser sphere(n) (sphere de (n+1) par (n+1))
Tu as accès aux valeurs par [x,y,z]=sphere(n) et là tu peux utiliser plot3(x,y,z)
....
Tu as la solution brutale :
clear
R=1;
n=1;
for theta=0:0.05:2*pi;
for phi=-pi/2:0.05:pi/2;
x(n)=R*cos(theta)*cos(phi);
y(n)=R*cos(theta)*sin(phi);
z(n)=R*sin(theta);
n=n+1;
end
end
plot3(x,y,z,'.','MarkerSize',1)
grid
En cherchant, tu aurais pu trouver sur l'excellent forum des développeurs à Matlab !
http://www.developpez.net/forums/d331619/autres-langages/algorithmes/mathematiques/algorithme-trace-sphere/Et pour le fun :
clear
vert=[1 1 1;1 2 1;2 2 1;2 1 1;1 1 2;1 2 2;2 2 2;2 1 2];
fac=[1 2 3 4;2 6 7 3;4 3 7 8;1 5 8 4;1 2 6 5;5 6 7 8];
sphere(36);
h=findobj('Type','surface');
set(h,'FaceColor','interp',...
'EdgeColor',[.4 .4 .4],...
'BackFaceLighting','lit')
hold on
patch('faces',fac,'vertices',vert,'FaceColor','y');
light('Position',[1 3 2]);
light('Position',[-3 -1 3]);
material shiny
axis vis3d off
hold off