1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| clear
L=10;% Longueur du segment
x0=10;y0=10;% Coordonnées initiales du milieu
alpha0=30;% Angle initial
V=L*[cosd(alpha0) sind(alpha0)];
h1=line([x0-V(1)/2 x0+V(1)/2],[y0-V(2)/2 y0+V(2)/2]);% Rotation autour du centre
text(x0-V(1)/2,y0-V(2)/2,'zone 1')
%h1=line([x0 x0+V(1)],[y0 y0+V(2)]);text(x0,y0,'zone 1');% Rotation autour de l'origine du segment
set(h1,'Color','r','LineStyle','--')
grid
axis square
axis([0 20 0 20])
alpha = 60;% Choix de l'angle
alpha=alpha0-alpha;% Calcul de la rotation
VR=V*[cosd(alpha) -sind(alpha); sind(alpha) cosd(alpha)];%Rotation du segment
hold on
h2=line([x0-VR(1)/2 x0+VR(1)/2],[y0-VR(2)/2 y0+VR(2)/2]);% Rotation autour du centre
text(x0-VR(1)/2,y0-VR(2)/2,'zone 1')
%h2=line([x0 x0+VR(1)],[y0 y0+VR(2)]);text(x0,y0,'zone 1');% Rotation autour de l'origine du segment
set(h2,'Color','b') |
Partager