%% Create r,theta coordinates for parameter space [0,pi/2] \times [-pi,\pi].
%%
%% Imagine making a 40x50 grid in this space of points p_{ij}.  The following command makes matrices
%% r_ij and theta_ij consisting of the r and theta coordinates respectively of the points p_ij
[r,theta] = meshgrid( linspace(0,pi/2,40), linspace(-pi,pi,50) );

%% It is now easy to make the images of the points p_ij in R^3
x = sin(r).*cos(theta);
y = sin(r).*sin(theta);
z = cos(r);

%% These points form the upper half sphere.  You could plot it with
% surf(x,y,z).  But we want the projective plane, so we pass those
% points through the map we described in class.

% Draw the surface 
surf(x.*y,y.*z,z.*x)

% Make it a pretty color
colormap(winter)

% Set axes to be equally scaled.
axis equal
% Keep axis scaling fixed when we rotate it interacively
axis vis3d
