// svd plot
function pts = spherepoints(d,n)
  pts = rand(d,n);
  pts(:) = pts(:) - 0.5;
  for i = 1:n
     pts(:,i) = pts(:,i)/norm(pts(:,i));
  end
endfunction

function plot3dpoints(vec)
drawlater;
  param3d(vec(1,:),vec(2,:),vec(3,:));
  a=gca();
  a.isoview="on";
  p=a.children(1);
  p.mark_mode="on";
  p.line_mode="off";
drawnow;
endfunction

clf;
n = 1000;
vec = spherepoints(3,n);
subplot(1,2,1);
plot3dpoints(vec);

subplot(1,2,2);
A = [4 11 14;8 7  -2];
vec2=zeros(2,n);
for i = 1:n
	vec2(:,i)=A*vec(:,i);
end
drawlater;
plot(vec2(1,:),vec2(2,:),'k.');
  a=gca();
  a.isoview="on";
  p=a.children(1);
  p=p.children(1);
  p.mark_size=0.5;
drawnow;

scf(1);
clf;
n = 100;
vec = spherepoints(2,n);
subplot(1,2,1)
drawlater;
plot(vec(1,:),vec(2,:),'k.');
  a=gca();
  a.isoview="on";
  p=a.children(1);
  p=p.children(1);
  p.mark_size=0.5;
drawnow;

subplot(1,2,2);
vec2=zeros(3,n);
for i = 1:n
	vec2(:,i)=A'*vec(:,i);
end
drawlater;
  param3d(vec2(1,:),vec2(2,:),vec2(3,:));
  a=gca();
  a.isoview="on";
  p=a.children(1);
  p.mark_mode="on";
  p.line_mode="off";
drawnow;
