FUNCTION Q_rot,qrot,qvec
sr = size(qrot)
sv = size(qvec)
nr = (sr(0) eq 1) + (sr(0) eq 2)*sr(2)
nv = (sv(0) eq 1) + (sv(0) eq 2)*sv(2)
err = bytarr(3)
err(0) = sr(1) ne 4 or nr eq 0
err(1) = sv(1) ne 4 or nv eq 0
err(2) = not (nr eq 1 or nv eq 1 or (nr eq nv and nr ne 1 and nv ne 1) )
err = err mod 2
if (where(err ne 0))(0) ne -1 then begin
print,"Q_ROT : error, wrong argument size..."
print," Use : Q_ROT,qrot,qvec"
if err(0) then print," > qrot must be a quaternion (4) or a vector of quaternions (4,n)"
if err(1) then print," > qvec must be a quaternion (4) or a vector of quaternions (4,n)"
if err(2) then print," > in case of vector of quaternions (4,n1) and (4,n2), n1=n2 is required"
return,-1
endif
qres = Q_prod(Q_prod(qrot,qvec),Q_conj(Qrot))
return,qres
end