function Paraboloid

% http://geometrie.hs-nb.de/MATLAB-Programme/Paraboloid.m   Bearbeitungsstand: 19.2.2005
% (C) Martin Nitschke, nitschke@hs-nb.de

close all
deg=pi/180;
p=5;
a=4;
b=6;
h=0.5;
D=[-b b];
zStr=char(subs('t^2/(2*p)','p',p));
zInl=inline(zStr,'t');
[x,z]=fplot(zInl,[-b b]);

figure('numbertitle','off','name','Parabel');
plot(x,z,'k')
hold('on')
[x,z]=fplot(zInl,[0 a]);
[xG yG]=meshgrid([-b -a a b],[0 p/2 zInl(b)]);
plot(0,p/2,'.k','MarkerSize',30)
plot(xG,yG,xG',yG','color',0.5*[1 1 1]);
plot(x,z,'k','linewidth',2.0);
plot(D,[0 0],'k');
plot([0 0],[0 zInl(b)],'k','erase','none')
Spitze([b;0],[1;0],h,30*deg,'k');
Spitze([0;zInl(b)],[0;1],h,30*deg,'k');
Schrift([b-0.1*h;0],'\itx','HorizontalAlignment','right','VerticalAlignment','bottom')
Schrift([0;zInl(b)],'\itz','HorizontalAlignment','center','VerticalAlignment','bottom')
Schrift([0;p/2],'{\itF}(0,0,{\itp}/2)','HorizontalAlignment','left','VerticalAlignment','top')
Schrift([ a;0.1*h],'\ita','HorizontalAlignment','center','VerticalAlignment','top')
Schrift([ 0;0.1*h],'0','HorizontalAlignment','center','VerticalAlignment','top')
Schrift([-a;0.1*h],'-\ita','HorizontalAlignment','center','VerticalAlignment','top')
Schrift([-b;p/2],'{\itp}/2 ','HorizontalAlignment','right','VerticalAlignment','middle')
Schrift([-b;0],'0 ','HorizontalAlignment','right','VerticalAlignment','middle')
axis('off')
hold('off')
axis('equal')
axis([D -h zInl(b)])
print('-deps','Paraboloid-1')

figure('numbertitle','off','name','Paraboloid');
zInl=inline(vectorize(zStr),'t');
[x,z]=fplot(zInl,[-b b]);
plot3(x,zeros(size(x)),z,'k')
hold('on')
[x,z]=fplot(zInl,[0 a]);
plot3(x,zeros(size(x)),z,'k','linewidth',2.0)
[Lambda,Rho]=meshgrid([0:360]*deg,x);
X=Rho.*cos(Lambda);
Y=Rho.*sin(Lambda);
Z=zInl(Rho);
surf(X,Y,Z,asin(Z./sqrt(X.^2+Y.^2+Z.^2)));
c=0.5+0.375*(sin(0.5*pi*[0:size(X,1)-1]/(size(X,1)-1))).^2;
colormap(repmat(c',1,3));
shading('interp')
view(0,20);
axis('equal')
axis([-5 5 -4 3.8 1 2])
axis('off')
print('-deps','Paraboloid-2','-opengl')


function Schrift(P,txt,varargin)
if length(P)==2
  P=[P;0];
end
text(P(1),P(2),P(3),txt,'FontName','TimesNewRoman','FontSize',34,varargin{:});

function Spitze(P,v,L,phi,varargin);
if nargin<=2
  L=1;
end
if nargin<=3
  phi=7.5*pi/180;
end
ta=tan(phi/2);
v=L*v./repmat(sqrt(dot(v,v)),size(P,1),1);
n=[-v(2,:);v(1,:)];
Q=P-v+ta*n;
R=P-v-ta*n;
for k=1:size(P,2);
  fill([P(1,k) Q(1,k) R(1,k)],[P(2,k) Q(2,k) R(2,k)],varargin{:})
end

