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) ;

Antworten (1)

Akira Agata
Akira Agata am 20 Nov. 2017

1 Stimme

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 Kommentare

Claire Low
Claire Low am 20 Nov. 2017
Hi! I only want a 2-D plot - so a circular segment, not a 3-D plot. I will eventually be plotting many of these on top of each other so will be better in 2-D.
Akira Agata
Akira Agata am 21 Nov. 2017
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
Claire Low am 21 Nov. 2017
Hi! So it would be a circular segment and just look like the top part of the sphere or just the green part of the image here https://en.wikipedia.org/wiki/Circular_segment
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
Carlos Reyes am 14 Feb. 2019
Bearbeitet: Carlos Reyes am 14 Feb. 2019
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')

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 20 Nov. 2017

Bearbeitet:

am 14 Feb. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by