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 で Labels and Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!