function A = methdef
close all
A = [ -1  -1  -1  1  1  1  0  0  0  0  0  0  0  0  0 
      1  1  -1  0  0  0  -1  -1  1  0  0  0  0  0  0 
      -1  1  1  0  0  0  0  0  0  1  -1  -1  0  0  0 
      1  -1  1  0  0  0  0  0  0  0  0  0  -1  1  -1];
%A = A(:,4:15);
S = A'*A;
[V,D]=eig(S);
d = diag(D);
%return
vec = null(S-3*eye(15),'r');
vec = [vec null(S-7*eye(15),'r')];
disp([d vec])

[xs,ys,zs] = sphere;
r = 0.1;
xs = r*xs; ys = r*ys; zs = r*zs;

for j=1:300
    t = 3*2*pi*(j-1)/100;
    for n=1:4
        metheig(vec(:,n)/4,n,t,xs,ys,zs)
    end    
end

% build a geometric null space for remaining modes
z = zeros(15,1);
xt = z; xt(1:3:15) = 1;
yt = z; yt(2:3:15) = 1;
zt = z; zt(3:3:15) = 1;
rxyd = z; rxyd([4 5]) = [1 -1];
rxzd = z; rxzd([4 6]) = [1 -1];
rxyc = z; rxyc([7 8]) = [1 -1];
rxzc = z; rxzc([7 9]) = [1 1];
rxyb = z; rxyb([10 11]) = [1 1];
rxzb = z; rxzb([10 12]) = [1 1];
rxya = z; rxya([13 14]) = [1 1];
rxza = z; rxza([14 15]) = [1 1];
gA = [xt yt zt rxyd rxzd rxyc rxzc rxyb rxzb rxya rxza];
%keyboard
return

function metheig(v,n,t,xs,ys,zs)
subplot(2,2,n)
x = [0 1] + sin(t)*[v(1) v(4)];
y = [0 1] + sin(t)*[v(2) v(5)];
z = [0 1] + sin(t)*[v(3) v(6)];
plot3(x,y,z)
%axis off
hold on
surf(x(1)+xs,y(1)+ys,z(1)+zs)
surf(x(2)+xs,y(2)+ys,z(2)+zs)
x = [0 -1] + sin(t)*[v(1) v(7)];
y = [0 -1] + sin(t)*[v(2) v(8)];
z = [0 1] + sin(t)*[v(3) v(9)];
plot3(x,y,z)
surf(x(2)+xs,y(2)+ys,z(2)+zs)
x = [0 1]+ sin(t)*[v(1) v(10)];
y = [0 -1] + sin(t)*[v(2) v(11)];
z = [0 -1] + sin(t)*[v(3) v(12)];
plot3(x,y,z)
surf(x(2)+xs,y(2)+ys,z(2)+zs)
x = [0 -1] + sin(t)*[v(1) v(13)];
y = [0 1] + sin(t)*[v(2) v(14)];
z = [0 -1] + sin(t)*[v(3) v(15)];
plot3(x,y,z)
surf(x(2)+xs,y(2)+ys,z(2)+zs)
axis(1.5*[-1 1 -1 1 -1 1])
drawnow
hold off
return

