%% SH example
clear all;
close all;
clc;

n= 100;
[x,y,z] = sphere(n);

l = 2;
m = 0;

Y = zeros(n+1,n+1);
x2=zeros(n+1);
y2=zeros(n+1);
z2=zeros(n+1);
for i=1:n+1
    for j=1:n+1
        [theta,phi,r] = cart2sph(x(i,j),y(i,j),z(i,j));
        Y(i,j) = real_sh(pi/2-phi,theta,l,m);
        [x2(i,j),y2(i,j),z2(i,j)] = sph2cart(theta,phi,1);%Y(i,j));
        
    end

end



figure
clf
sc=surf(x2,y2,z2,Y)
set(sc,'FaceAlpha',0.5, 'EdgeAlpha', 0,'edgecolor','none')
light
lighting phong
axis tight equal off
view(40,30)
camzoom(1.5)