clear all; close all; clc;
y=[2 4 6 8 10];
x=ones(size(y));
V=[x(:) y(:) zeros(size(y(:)))];
V_centre=mean(V,1);
Vc=V-ones(size(V,1),1)*V_centre;
a=30;
a_rad=((a*pi)./180);
E=[0 0 a_rad];
Rx=[1 0 0;...
0 cos(E(1)) -sin(E(1));...
0 sin(E(1)) cos(E(1))];
Ry=[cos(E(2)) 0 sin(E(2));...
0 1 0;...
-sin(E(2)) 0 cos(E(2))];
Rz=[cos(E(3)) -sin(E(3)) 0;...
sin(E(3)) cos(E(3)) 0;...
0 0 1];
R=Rx*Ry*Rz;
Vrc=[R*Vc']';
Vruc=[R*V']';
Vr=Vrc+ones(size(V,1),1)*V_centre;
figure;
plot3(V(:,1),V(:,2),V(:,3),'k.-','MarkerSize',25); hold on;
plot3(Vr(:,1),Vr(:,2),Vr(:,3),'r.-','MarkerSize',25);
plot3(Vruc(:,1),Vruc(:,2),Vruc(:,3),'b.-','MarkerSize',25);
axis equal; view(3); axis tight; grid on;
Best Answer