How to fill a region defined by coordinates?

15 次查看(过去 30 天)
How to fill the area enclosed by points A,E and F.
% A B E F points
rO= [ 0 , 0 ];
rA = [ -w*cos(f)/2 + sin(f) , -cos(f) - w*sin(f)/2 ];
rB = [ w*cos(f)/2 + sin(f) , -cos(f) + w*sin(f)/2 ];
relEA= [ ww*cos(f) , ww*sin(f) ];
relFA= [-hh*sin(f) , hh*cos(f) ];
rE = relEA + rA;
rF = relFA + rA;
%Plotting and Connecting A,E,F points to get a triangle
figure,
plot(rA(1),rA(2),'r*',rE(1),rE(2),'g*',rF(1),rF(2),'b*',rB(1),rB(2),'k*', rO(1),rO(2),'m*'); hold on;
axis([-2 2 -2 2]);
line([rA(1), rB(1)],[rA(2),rB(2)]); hold on;
line([rA(1), rF(1)],[rA(2),rF(2)]); hold on;
line([rE(1), rF(1)],[rE(2),rF(2)]);

采纳的回答

Geoff Hayes
Geoff Hayes 2019-3-9
Mirlan - you can use fill to colour the area enclosed by your three points. For example, you can add the following to the end of your code
X = [rA(1); rB(1); rF(1)];
Y = [rA(2); rB(2); rF(2)];
fill(X, Y, 'g');
to fill the area in green.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Labels and Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by