How to plot a spherical cap in 2-D

7 ビュー (過去 30 日間)
Claire Low
Claire Low 2017 年 11 月 20 日
編集済み: Carlos Reyes 2019 年 2 月 14 日
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
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 件のコメント
Akira Agata
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
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')

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by