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

hf = figure(1); 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, 'k-', 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

plot3(x,  sqrt(1+x.^2), ones(size(x)), 'r-', lw, 4)
plot3(x, -sqrt(1+x.^2), ones(size(x)), 'r-', lw, 4)

pause

plot3( sqrt(1+y.^2), y, -ones(size(y)), 'b-', lw, 4)
plot3(-sqrt(1+y.^2), y, -ones(size(y)), 'b-', lw, 4)

pause

plot3(x, x, 0*x, 'g-', lw, 4)
plot3(x, -x, 0*x, 'g-', lw, 4)


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);


% add some extra hyperbolas
plot3(x,  sqrt(2+x.^2), 2*ones(size(x)), 'm-', lw, 4)
plot3(x, -sqrt(2+x.^2), 2*ones(size(x)), 'm-', lw, 4)

plot3( sqrt(2+y.^2), y, -2*ones(size(y)), 'c-', lw, 4)
plot3(-sqrt(2+y.^2), y, -2*ones(size(y)), 'c-', lw, 4)

%% other options:
%shading interp
%camlight left
