function Rotationskoerper

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

deg=pi/180;
syms('t','u','v','real');
clc;
close('all')
c=(3+sin(3*t)*cos(5*t)/(1+sin(exp(t))^2))*[cos(t);sin(t);0]+[10;0;0];
Phi=RK(c,t,sym([0;1;0]),u,v);
xRKInl=inline(vectorize(Phi(1)),'u','v');
yRKInl=inline(vectorize(Phi(2)),'u','v');
zRKInl=inline(vectorize(Phi(3)),'u','v');
[U,V]=meshgrid([0:5:360]*deg,linspace(0,2*pi,64));
X=xRKInl(U,V);
Y=yRKInl(U,V);
Z=zRKInl(U,V);
surf(X,Y,Z,V);
c=0.5+0.375*(sin(pi*[0:size(V,2)-1]/(size(V,2)-1))).^2;
colormap(repmat(c',1,3));
hold('on')
uRef=round(0.35*size(U,1));
plot3(X(uRef,:),Y(uRef,:),Z(uRef,:),'k','linewidth',4.0)
Schrift([X(uRef,1);Y(uRef,1);Z(uRef,1)],{'Profil-^{ }' 'kurve'},'HorizontalAlignment','right','VerticalAlignment','top','erase','none')
Schrift([0;0;0],'Achse^{  }','Rotation',90,'HorizontalAlignment','center','VerticalAlignment','bottom','erase','none')
plot3(X,Y,Z,'k')
plot3([0;0], [min(Y(:));max(Y(:))]+2*(max(Y(:))-min(Y(:)))*[-1;1],[0;0],'k','linewidth',2.0)
axis('equal')
axis([min(X(:)) max(X(:)) min(Y(:)) max(Y(:)) -11 12])
axis('off')
shading('interp')
view(0,-50)
print('-deps','Rotationskoerper','-opengl')

function Phi=RK(c,t,q,u,v);
Phi=(cos(v)*sym(eye(3))+(1-cos(v))*q*q'-sin(v)*[0 q(3) -q(2);-q(3) 0 q(1);q(2) -q(1) 0])*subs(c,t,u);

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