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!