Borrar filtros
Borrar filtros

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

8 visualizaciones (últimos 30 días)
题目:绘制球体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 comentarios
Dyuman Joshi
Dyuman Joshi el 25 de Abr. de 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?
根红
根红 el 5 de Mayo de 2024
What I mean is to make a stereoscopic graph in the first octant part; That is, closed stereogram.

Iniciar sesión para comentar.

Respuestas (1)

warnerchang
warnerchang el 26 de Abr. de 2024
Editada: Walter Roberson el 26 de Abr. de 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)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by