フィルターのクリア

How to draw D in 3D ?

3 ビュー (過去 30 日間)
Tran Phuc
Tran Phuc 2016 年 7 月 9 日
編集済み: Carlos Guerrero García 2022 年 12 月 2 日
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 日
編集済み: 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 Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by