function q=qrot(v,fi,varargin)
f=fi/2;
v=v/norm(v);
s=cosd(f); x=v(1)*sind(f); y=v(2)*sind(f); z=v(3)*sind(f);
q(1,1:4)=[s; x; y; z];

if nargin==3
    if strcmp(varargin{1},'matrix')
        q(2:4,1:4)=[-x s -z y;
                    -y z s -x;
                    -z -y x s];
    end
end
