How to fill a region defined by coordinates?
11 次查看(过去 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)]);
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!