How to shade the area between two mirror curves using patch?
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jnandeep Talukdar
el 1 de Mzo. de 2021
Comentada: Star Strider
el 2 de Mzo. de 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 comentario
Respuesta aceptada
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
Más respuestas (0)
Ver también
Categorías
Más información sobre Polygons en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!