Recently I had to solve a simple problem in which I had a sphere of radius $R$ with a constant potential (but with different sign), on both of the hemispheres, and I was asked to get the electrostatic potential for every point in the space. And I had to do it with both hemispheres along the $z$-axis, and then solve the same problem but with the hemispheres along the $y$-axis. So I solved both of the problems, first with the potential with Legendre generator function and azimuthal symmetry, and the second with the expression of the potential with spherical harmonics. But the last question was to find the matrix rotation in order to show that both solutions are the same?. And this is what I don't understand, is there a relation between the Legendre generator function and Spherical Harmonics for rotations?
First solution of the potential, taking the general solution with azimuthal symmetry: $$ \phi (r,\theta)=\sum^{\infty}_{l=0}\left(A_{l}r^{l}+\dfrac{B_{l}}{r^{l+1}}\right)P_{l}(\cos\theta)$$ with boundary conditions: $$ a)\phi(R,\theta)=\phi_{o};\text{ if }\theta \in [0,\pi /2) \\ \phi(R,\theta)=-\phi_{o};\text{ if } \theta \in [\pi /2, \pi]\\ b)r\rightarrow \infty; \phi(r)=0\\ c)r=0; \phi(r);\text{ finite } $$ getting the potential for inside and outside the sphere. $$ \phi (r,\theta)_{inside}=\sum^{\infty}_{l=0}(A_{l}r^{l})P_{l}(\cos\theta)\\ \Rightarrow A_{l}=\phi_{0}\left[\int_{0}^{1}P_{l}(x)dx\right]\left(\dfrac{2l+1}{R^{l}}\right); \forall l=1,3,5,... \\\phi (r,\theta)_{outside}=\sum^{\infty}_{l=0}\dfrac{B_{l}}{r^{l+1}}P_{l}(\cos\theta)\\ \Rightarrow B_{l}=\phi_{0}[\int_{0}^{1}P_{l}(x)dx](2l+1)R^{l+1}; \forall l=1,3,5,...$$
Then the second solution, with the sphere rotated 90 degrees around the $YZ$ plane; $$ \phi (r,\theta,\varphi)=\sum^{\infty}_{l=0}\sum^{l}_{m=-l}(A_{l,m}r^{l}+\dfrac{B_{l,m}}{r^{l+1}})Y_{l,m}(\theta,\varphi)$$ with boundary conditions: $$ a)\phi(R,\theta)=\phi_{o}; if \varphi \in [0,\pi)\\ \phi(R,\theta)=-\phi_{o}; if \varphi \in [\pi, 2\pi]\\ b)r\rightarrow \infty; \phi(r)=0\\ c)r=0; \phi(r);finite $$ getting the potential for inside and outside the sphere. $$ \phi (r,\theta,\varphi)_{inside}=\sum^{\infty}_{l=0}\sum^{l}_{m=-l}(A_{l,m}r^{l})Y_{l,m}(\theta,\varphi)\\ \Rightarrow A_{l,m}=R^{-l}\dfrac{4\phi_{o}}{im}\sqrt{\dfrac{2l+1}{4\pi}\dfrac{(l-m)!}{(l+m)!}}\left[\int_{-1}^{1} P_{l}^{m}(x)d(x)\right];\forall l\in\mathbb{N},\forall m=1,3,5,...\\ \phi (r,\theta,\varphi)_{outside}=\sum^{\infty}_{l=0}\sum^{l}_{m=-l}(\dfrac{B_{l,m}}{r^{l+1}})Y_{l,m}(\theta,\varphi)\\ \Rightarrow B_{l,m}=R^{l+1}\dfrac{4\phi_{o}}{im}\sqrt{\dfrac{2l+1}{4\pi}\dfrac{(l-m)!}{(l+m)!}}\left[\int_{-1}^{1} P_{l}^{m}(x)d(x) \right];\forall l\in\mathbb{N},\forall m=1,3,5,...$$