How to fill a region defined by coordinates?
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mirlan Karimov
am 9 Mär. 2019
Beantwortet: Geoff Hayes
am 9 Mär. 2019
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 Kommentare
Akzeptierte Antwort
Geoff Hayes
am 9 Mär. 2019
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Labels and Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!