How to draw D in 3D ?

3 Ansichten (letzte 30 Tage)
Tran Phuc
Tran Phuc am 9 Jul. 2016
D defined by x^2+y^2+z^2=4 and x+y+z=0

Antworten (2)

KSSV
KSSV am 9 Jul. 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)

Carlos Guerrero García
Carlos Guerrero García am 2 Dez. 2022
Bearbeitet: Carlos Guerrero García am 2 Dez. 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

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by