function R = RotMat3D(rotaxis,angle)
% R = RotMat3D(rotaxis,angle)
% computes a rotation matrix for a arbitrary axis and angle.
% Using Rodrigues' formula in matrix exponential form.
% rotaxis is assumed to be unit length.
% angle within [0, 2*pi]


% create cross product matrix, such that A*x = cross(rotaxis,x)
A = [0 -rotaxis(3) rotaxis(2); 
	 rotaxis(3) 0 -rotaxis(1); 
     -rotaxis(2) rotaxis(1) 0];

% rotation matrix is given by the matrix exponential
R = expm(angle*A);
