function v=sh_rotate(v,xi,theta,phi)
% v=sh_rotate(v,xi,theta,phi)
%
% recombines the elements of the (nmax+1)^2 elements vector
% of spherical harmonics coefficients v in order to express
% a rotation by the z-y-z Euler-angles xi,theta,phi
%
% For reference on representation of a zyz rotation in terms of a
% z y(pi/2) z y(pi/2) z, see for example Pinchon and Hoggan 2007,
% "rotation matrices for real spherical harmonics", Journal of Physics.
%
% see also sh_rotate_z, sh_rotate_y90,
% chebyshev12, wigner_d90_real
%
% Implementation and derivation from the complex-valued recurrence relations
% in Gumerov and Duraiswami (2001,2003,2004: "recursive, fast and stable..."/
% "fast multipole methods for the helmholtz equation in three dimensions" ...)
% by Franz Zotter, Institute of Electronic Music and Acoustics
% (IEM), University of Music and Dramatic Arts (KUG), Graz, Austria
% http://iem.at/Members/zotter, 2009.
%
% This code is published under the Gnu General Public License, see
% "LICENSE.txt"
nmax=sqrt(size(v,1))-1;
d90=wigner_d90_real(nmax);
v=sh_rotate_z(v,xi+pi/2);
v=sh_rotate_y90(v,d90);
v=sh_rotate_z(v,theta+pi);
v=sh_rotate_y90(v,d90);
v=sh_rotate_z(v,phi+pi/2);