How to shade the area between two mirror curves using patch?

14 visualizaciones (últimos 30 días)
Hello,
I wanted to shade the area between the curve C1 and C2 shown in the figure below.
The vector for curve C2 is:
alpha = 150 : 2 : 210;
pp = [cosd(alpha')+sind(60)+0.5 sind(alpha')+cosd(60)];
pp = flip(pp);
I am trying to shade the area using patch (shaded red in figure) but getting it shaded in other adjacent parts. Please do help and if you need any other information, comment below.

Respuesta aceptada

Star Strider
Star Strider el 1 de Mzo. de 2021
I am not certain how ‘C_1’ and ‘C_2’ were created, however this is one approach to filling the space between them (creating them as circle arcs):
t = linspace(-pi/4, pi/4); % Parameter Vector
r = 5; % Radius
x = r*cos(t); % x-Coordinate Of Curves
y = r*sin(t); % y-Coordinate Of Curves
xp(1,:) = x-r*1.25; % Left Side ‘x’ Vector
xp(2,:) = 1.25*r-x; % Right Side ‘x’ Vector
figure
plot(xp(1,:), y, '-k', xp(2,:), y, '-k') % Draw Curves
hold on
patch([xp(1,:) xp(2,:)], [y fliplr(y)], 'r') % Fill Between Curves
hold off
axis('equal')
producing:
.
  2 comentarios
Jnandeep Talukdar
Jnandeep Talukdar el 2 de Mzo. de 2021
Thank you very much for your help. C1 and C2 are a bit different but I have got the idea and the code worked. Thanks again.
Star Strider
Star Strider el 2 de Mzo. de 2021
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by