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

조회 수: 1 (최근 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?
根红
根红 2024년 5월 5일
What I mean is to make a stereoscopic graph in the first octant part; That is, closed stereogram.

댓글을 달려면 로그인하십시오.

답변 (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