
How to plot a spherical cap in 2-D
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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) ;
0 Kommentare
Antworten (1)
Akira Agata
am 20 Nov. 2017
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
Akira Agata
am 27 Nov. 2017
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
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')
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!