这是一个围绕原点 (0,0) 旋转两个点并在绘图上显示结果的函数。
更新
function [Af,Bf] = rotateTwoPoints (A,B,t)
% Definition of the rotation matrix (rotation around origin (0,0) )
R=[ ...
cosd(t) -sind(t)
sind(t) cosd(t)
];
% rotation of the points A and B
Af = R*A;
Bf = R*B;
% Plot of the original line
plot(A(1),A(2),'k*', B(1),B(2),'b*');
line([A(1) B(1)],[A(2) B(2)], 'Color','r');
grid on
hold on
% Plot of the rotated line
plot(Af(1),Af(2),'g*', Bf(1),Bf(2),'r*');
line([Af(1) Bf(1)],[Af(2) Bf(2)], 'Color','b');
legend('A','B','line AB','Af','Bf','line AfBf','Location','northeastoutside');
daspect([1 1 1])
图像旋转 A(13,20) , B(13,100) 和 t= 10°
[Af,Bf] = rotateTwoPoints(A,B,10)