필터 지우기
필터 지우기

How to fill a region defined by coordinates?

조회 수: 12 (최근 30일)
Mirlan Karimov
Mirlan Karimov 2019년 3월 9일
답변: Geoff Hayes 2019년 3월 9일
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에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by