clear 
 n = [0; 1;  1]/sqrt(2); % rotation axis (unit vector) 
%n = [0; 0;  1]; % another rotation axis (unit vector) 
r = [1; 1; 0]; % initial position is parallel to the x axis

N = 100; 
phi = linspace(0,2*pi,N); % N different angles between 0 and 2 pi;
			  % note n and N are different variables,
			  % matlab is case sensitive
R1 = cross(n,r);			  
R2 = cross(n,R1);

v = linspace(0,1,100);   % hundred points between 0 and 1
rot_axis_x = n(1)*v*2 ;
rot_axis_y = n(2)*v*2 ;
rot_axis_z = n(3)*v*2 ; 

plot3(rot_axis_x,rot_axis_y,rot_axis_z,'r','Linewidth',4) ; 
% draw the rotation axis as  a thick red line 
hold on  % keep working on the same plot...
			
set(gca,'FontSize',20);	%fixes the size of the symbols			
 
Rx = r(1) + R2(1)*(1-cos(phi)) + R1(1)*sin(phi);
Ry = r(2) + R2(2)*(1-cos(phi)) + R1(2)*sin(phi);
Rz = r(3) + R2(3)*(1-cos(phi)) + R1(3)*sin(phi);

%these are the three coordinates of the end-point of the  vector
% rotated by phi	
plot3(Rx,Ry,Rz,'.')
%plot the endpoints as dots

plot3(Rx(1)*v,Ry(1)*v,Rz(1)*v,'k','Linewidth',2) 
plot3(Rx(20)*v,Ry(20)*v,Rz(20)*v,'m','Linewidth',2) 
plot3(Rx(50)*v,Ry(50)*v,Rz(50)*v,'g','Linewidth',2) 
plot3(Rx(70)*v,Ry(70)*v,Rz(70)*v,'c','Linewidth',2) 
%plot four selected vectors 
xlabel('x','FontSize',16);
ylabel('y','FontSize',16)
zlabel('z','FontSize',16)

hold off %release the plot
