How to plot a spherical cap in 2-D
显示 更早的评论
I would like to know how to plot the top part of a sphere or the spherical cap in 2-D (circular segment) as shown here: http://mathworld.wolfram.com/SphericalCap.html. I already know the radius of the spherical cap, a1, the contact angle, theta (the angle between the normal to the sphere at the bottom of the cap and the base plane) and the height of the spherical cap, h.
a1 = 1;
theta = 1.34; %in radians
h = a1 * (1 - cos(theta)) / sin(theta) ;
回答(1 个)
Akira Agata
2017-11-20
I think fsurf function would be help, like:
funx = @(theta,phi) sin(theta).*cos(phi);
funy = @(theta,phi) sin(theta).*sin(phi);
funz = @(theta,phi) cos(theta);
fsurf(funx,funy,funz,[0 1.34 -pi pi]) % plot the cap where theta = 0 ~ 1.43 radian

5 个评论
Claire Low
2017-11-20
Akira Agata
2017-11-21
Hi Claire-san,
Thank you for your reply. Sorry, I don't understand what "2-D plot" means. Is that a cutting-edge of the cap (= circle) ??
Claire Low
2017-11-21
Akira Agata
2017-11-27
Thanks for the clarification!
OK. Then, how about the following example? I hope this would be similar to what you want to plot.
a1 = 1;
theta = 1.34; %in radians
t = linspace(-theta/2 + pi/2, theta/2 + pi/2);
x = a1*cos(t);
y = a1*sin(t);
figure
fplot(@(phi) a1*sin(phi), @(phi) a1*cos(phi),[0 2*pi],'k:')
hold on
patch(x,y,'g')

Carlos Reyes
2019-2-14
编辑:Carlos Reyes
2019-2-14
Greetings,
Can you show how would you go about coloring other areas in this sphere? For example say I would like to color in blue the area from 0.8 down to 0 in a blue color.
I tried it like this: (but this not cover the area completely)
R = 1 ;
theta = 1.85; %in radians
t = linspace(-theta/2 + pi/2, theta/2 + pi/2);
x = R*cos(t);
y = R*sin(t);
R2 = 0.6;
theta2 = 3.16; %radians
t2= linspace(-theta2/2 + pi/2, theta2/2 + pi/2);
x2= R2*cos(t2);
y2= R2*sin(t2);
figure
fplot(@(phi) R*sin(phi), @(phi) R*cos(phi),[0 2*pi],'k:')
hold on
patch(x,y,'b')
patch(x2,y2,'g')
类别
在 帮助中心 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!