function R = viprectification_rotmat(angs,str)
%Generate a rotation matrix.
%  R = VIPRECTIFICATION_ROTMAT(ANGS,STR) where STR is a string of 'x', 'y',
%  or 'z' values indicating the pivot dimensions of the corresponding
%  angles.

    R = eye(3);
    for i=1:min( length(angs), length(str) )
        a = angs(i);
        if strcmpi(str(i),'x')
            R = [1 0 0; 0 cos(a) -sin(a); 0 sin(a) cos(a)] * R;
        elseif strcmpi(str(i),'y')
            R = [cos(a) 0 -sin(a); 0 1 0; sin(a) 0 cos(a)] * R;
        elseif strcmpi(str(i),'z')
            R = [cos(a) -sin(a) 0; sin(a) cos(a) 0; 0 0 1] * R;
        end
    end
end
