How to draw D in 3D ?

2 次查看(过去 30 天)
Tran Phuc
Tran Phuc 2016-7-9
D defined by x^2+y^2+z^2=4 and x+y+z=0

回答(2 个)

KSSV
KSSV 2016-7-9
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)

Carlos Guerrero García
编辑:Carlos Guerrero García 2022-12-2
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

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by