
dt = 2*pi/100;
theta = 0:dt:2*pi;

dp = pi/100;
phi = -pi/2:dp:pi/2;

n = length(theta);
m = length(phi);

for i=1:n
  for j=1:m
    x(i,j) = cos(theta(i))*cos(phi(j)) ; 
    y(i,j) = sin(theta(i))*cos(phi(j)) ; 
    z(i,j) = sin(phi(j)) ; 
  end
end

figure(1)
surf(x,y,z);
% to make the axis have x_min = -1, x_max = 1, y_min = -2,
% y_max = 2, z_min = -5, z_max = 5, 
% type "axis([-1,1,-2,2,-5,5])"

A = rand(3,3);

for i=1:n
  for j=1:m
    w = [x(i,j) ; y(i,j) ; z(i,j)];
    zz = A*w;
    Ax(i,j) = zz(1);
    Ay(i,j) = zz(2);
    Az(i,j) = zz(3);
    l(i,j) = sqrt(zz(1)^2 + zz(2)^2 + zz(3)^2);
  end
end

max(max(l))
min(min(l))

figure(2)
surf(Ax,Ay,Az);
% to view from various angles in the xy plane,
% "view(0,0)", "view(90,0)", "view(180,0)", "view(270,0)", 
% to view from various heights,
% "view(0,-90)", "view(0,-45)", "view(0,0)", "view(0,45)", "view(0,90)",
