How to make a graph (or part of a graph) of space from a given equation or inequality

3 次查看(过去 30 天)
题目:绘制球体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 个评论
Dyuman Joshi
Dyuman Joshi 2024-4-25
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?

请先登录,再进行评论。

回答(1 个)

warnerchang
warnerchang 2024-4-26
编辑:Walter Roberson 2024-4-26
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)

类别

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