hold on;
rotate3d on;

% Critical points of f(x,y,z) = y^2 - z on S^2.

%% ----------------------------------------------------------------
[y,z] = meshgrid(-1:.1:1,-1:.1:1);
f = y.^2 - z;
surf(y,z,f);
shading flat;

%% ----------------------------------------------------------------
figure;
contour(y,z,f);
shading flat;

%% ----------------------------------------------------------------
[phi,theta] = meshgrid(0:.1:pi+.1, 0:.1:2*pi+.1);
x = cos(theta).*sin(phi);
y = sin(theta).*sin(phi);
z = cos(phi);

f = y.^2 - z;

%% ----------------------------------------------------------------
figure;
rotate3d on;
surf(phi,theta,f);
shading flat;

%% ----------------------------------------------------------------
figure;
rotate3d on;
surf(x,y,z,f);
shading flat;

%h=get(gcf,'CurrentAxes')
%rotate(h,[#,#],#) ...


set(gcf, 'PaperPositionMode', 'Manual');
set(gcf, 'PaperPosition', [0 0 5.0 4.0])
print -depsc y2zt


