How to shade the area between two mirror curves using patch?
9 views (last 30 days)
Show older comments
Jnandeep Talukdar
on 1 Mar 2021
Commented: Star Strider
on 2 Mar 2021
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.
1 Comment
Accepted Answer
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
More Answers (0)
See Also
Categories
Find more on Polygons in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!