%% 253 demo: graphing the hyperbolic paraboloid
% 2016 W1: Colin Macdonald, public domain

hf = figure(2); clf;
axis equal
lw = 'linewidth';

% sets of points for x and y
x = linspace(-2, 2, 40);
y = linspace(-2, 2, 40);

plot3(0*y, y, y.^2, 'r-', lw, 4)

% font size nonsense
hc = get(hf, 'children'); set(hc, 'fontsize', 18)

xlim([-3 3])
ylim([-3 3])
zlim([-4 4])

grid on
hold on
xlabel('x'); ylabel('y'); zlabel('z')

pause

plot3(x, 0*x, -x.^2, 'k-', lw, 4)

pause


for i=4:-1:-4
  y2 = i/2*ones(size(x));
  h = plot3(x, y2, y2.^2 - x.^2, 'k-', lw, 4);
  set(h, 'color', [0 0 abs(i/4)]);
  pause(2)
end

pause

%% now we add a colourful 3D plot
% meshgrid makes a 2D grid of (x,y) points
[xx, yy] = meshgrid(x, y);
surf(xx, yy, yy.^2 - xx.^2);
