function dAP

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

close('all')
abc=[5 3 4];
P=sym('[u-sin(v)/10;v+0.1*u;(sin(7*u)+cos(5*u))*cos(5*v)/3]');
P=subs(P,{'a' 'b' 'c'},abc);
uRef=0.66;
vRef=0.6;
xStr=char(P(1));
yStr=char(P(2));
zStr=char(P(3));
J=jacobian(['[' xStr ';' yStr ';' zStr ']'],[sym('u') sym('v')]);
N=cross(J(:,1),J(:,2));
N=N/sqrt(dot(N,N));
xInl=inline(vectorize(xStr),'u','v');
yInl=inline(vectorize(yStr),'u','v');
zInl=inline(vectorize(zStr),'u','v');
NInl=inline(vectorize(['[' char(N(1)) ';' char(N(2)) ';' char(N(3)) ']']),'u','v');
uRg=linspace(-0.5*pi,1*pi,96);
vRg=linspace(0.15*pi,0.55*pi,96);
[U,V]=meshgrid(uRg,vRg);
X=xInl(U,V);
Y=yInl(U,V);
Z=zInl(U,V);
surf(X,Y,Z,Z);
hold('on')
cmap=0.5+0.375*(sin(0.5*pi*[0:size(U,1)-1]/(size(U,1)-1))).^2;
colormap(repmat(cmap',1,3));
shading('interp')
plot3(xInl(uRef,vRef),yInl(uRef,vRef),zInl(uRef,vRef),'ok','Markersize',10,'erase','none')
NRef=0.5*NInl(uRef,vRef);
plot3(xInl(uRef,vRef)+[0 NRef(1)],yInl(uRef,vRef)+[0 NRef(2)],zInl(uRef,vRef)+[0 NRef(3)],'--k','erase','none')
plot3(xInl(uRef,vRef)+NRef(1),yInl(uRef,vRef)+NRef(2),zInl(uRef,vRef)+NRef(3),'.k','Markersize',30,'erase','none')
Schrift([xInl(uRef,vRef)+NRef(1);yInl(uRef,vRef)+NRef(2);zInl(uRef,vRef)+NRef(3)],'\itA','Erase','none',...
  'HorizontalAlignment','right','VerticalAlignment','bottom')
Schrift([xInl(uRef,vRef);yInl(uRef,vRef);zInl(uRef,vRef)],'{\itP}({\its_A},{\itt_A})','Erase','none',...
  'HorizontalAlignment','right','VerticalAlignment','top')
o=-1.0;
Schrift([xInl(uRef+o,vRg(1));yInl(uRef+o,vRg(1));zInl(uRef+o,vRg(1))+0.12],'{\itP}({\its},{\itt})','Erase','none',...
  'HorizontalAlignment','right','VerticalAlignment','bottom')
uG=linspace(min(U(:)),max(U(:)),14);
vG=linspace(min(V(:)),max(V(:)),7);
[U,V]=meshgrid(uG,vRg);
X=xInl(U,V);
Y=yInl(U,V);
Z=zInl(U,V);
if max(size(X))==1
  X=repmat(X,size(V));
end
if max(size(Y))==1
  Y=repmat(Y,size(V));
end
if max(size(Z))==1
  Z=repmat(Z,size(V));
end
plot3(X,Y,Z,'color',0*[1 1 1],'linewidth',1.5);
[U,V]=meshgrid(uRg,vG);
X=xInl(U,V);
Y=yInl(U,V);
Z=zInl(U,V);
if max(size(X))==1
  X=repmat(X,size(V));
end
if max(size(Y))==1
  Y=repmat(Y,size(V));
end
if max(size(Z))==1
  Z=repmat(Z,size(V));
end
plot3(X',Y',Z','color',0*[1 1 1],'linewidth',1.5);

hold('off')
axis('equal')
view(-148,74);
axis([-0.5 1.2 0.5 0.9 -0.5 0.4])
axis('off')
print('-deps','dAFl')

function Schrift(P,txt,varargin)
text(P(1),P(2),P(3),txt,'FontName','TimesNewRoman','FontSize',37,varargin{:});
