How to make a graph (or part of a graph) of space from a given equation or inequality
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
题目:绘制球体x^2+y^2+z^2<=16与圆柱面x^2+y^2=4x所截的空间立体图形。
我的代码是:
%绘制球面
Question: Draw the spatial three-dimensional figure intercepted by the sphere x^2+y^2+z^2<=16 and the cylindrical surface x^2+y^2=4x.
My code is:
%Draw the sphere
phi=0:0.1:pi;
theta=-pi:0.1:pi;
[phi,theta]=meshgrid(phi,theta);
x1=4.*sin(phi).*cos(theta);
y1=4.*sin(phi).*sin(theta);
z1=4.*cos(phi);
surf(x1,y1,z1)
hold on
%绘制柱面
s=-5:0.1:5;
t=-pi:0.1:pi;
[s,t]=meshgrid(s,t);
x2=2+2*cos(t);
y2=2*sin(t);
z2=s;
surf(x2,y2,z2)
运行结果显示是两个空间曲面相交而成的图形。
我的问题:如何绘出在第一卦限部分的立体?
尝试:我通过更改参数的范围好像不能达到理想的图形。
The running result shows a graph formed by the intersection of two spatial surfaces.
My question: How to draw the solid in the first hexagram?
Try: I can't seem to achieve the ideal graph by changing the range of parameters.
3 commentaires
Dyuman Joshi
le 25 Avr 2024
You could use alphaShape to get the 3D surface, then use inShape to get the common area and use plot on it.
Though, you will have to adjust the alpha radius.
"我的问题:如何绘出在第一卦限部分的立体"
"My question: How to draw the solid in the first hexagram?"
This is not clear to me. Could you please elaborate on this?
Réponses (1)
warnerchang
le 26 Avr 2024
Modifié(e) : Walter Roberson
le 26 Avr 2024
Anything like this:
phi=0:0.1:pi;
theta=0:0.1:pi/2;
[phi,theta]=meshgrid(phi,theta);
x1=4.*sin(phi).*cos(theta);
y1=4.*sin(phi).*sin(theta);
z1=4.*cos(phi);
surf(x1,y1,z1)
hold on
%绘制柱面
s=-5:0.1:5;
t=0:0.1:pi/2;
[s,t]=meshgrid(s,t);
x2=2+2*cos(t);
y2=2*sin(t);
z2=s;
surf(x2,y2,z2)
1 commentaire
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!