How to draw D in 3D ?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
D defined by x^2+y^2+z^2=4 and x+y+z=0
0 commentaires
Réponses (2)
KSSV
le 9 Juil 2016
x = linspace(0,1) ;
y = linspace(0,1) ;
[X,Y] = meshgrid(x,y) ;
D1 = (4-X.^2+Y.^2).^0.5 ;
figure
surf(X,Y,D1) ;
% x+y+z=0
D2 = -(X+Y) ;
figure
surf(X,Y,D2)
0 commentaires
Carlos Guerrero García
le 2 Déc 2022
Modifié(e) : Carlos Guerrero García
le 2 Déc 2022
There is a wrong sign in the KSVV isolation of z in the first equality, and so, the D1 definition must be
D1=(4-X^2-Y^2).^0.5
Also, I think that Tran Phuc question is about a joint representation of D1, D2, and the curve intersecction of D1 and D2, and so, I suggest the following code:
[x,y]=meshgrid(-2:0.1:2);
z1=-(x+y);
surf(x,y,z1); %The plane
hold on;
[r,t]=meshgrid(0:0.1:2,0:pi/60:2*pi); % Polar coordinates are nice for sphere representations
x=r.*cos(t);
y=r.*sin(t);
z2=sqrt(4-r.^2);
surf(x,y,z2); % The upper semisphere
surf(x,y,-z2); % The lower semisphere
theta=0:pi/60:2*pi;
ro=sqrt(2./(1+sin(theta).*cos(theta))); % After solving the system by hand
x=ro.*cos(theta); % The classical conversion
y=ro.*sin(theta); % The classical conversion
plot3(x,y,-(x+y),'or','MarkerSize',3);
axis equal
0 commentaires
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots 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!