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

9 views (last 30 days)
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.

Accepted Answer

Star Strider
Star Strider on 1 Mar 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 Comments
Jnandeep Talukdar
Jnandeep Talukdar on 2 Mar 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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!