% parametric deformation of a plane into a figure of rotation.

clear all
clf

%make a flat surface
s1=UnitSurface(10);
s1.facelighting='flat';
s1.facecolor='red';

%%get the coordiates of the surface and deform them.
V=s1.vertices; 
%Note that on this plane there are only two non-zero coordinates:
%V(:,2) and V(:,1)
%V(:,2) is mapped into the long-axis of the cylinder
%V(:,1) is mapped into the circular direction with radius r
r=1.5 + abs(V(:,2)).*cos(2*pi*V(:,2));
%A cylinder with radius r, and its axis aligned along the Z axis
s1.vertices=[cos(pi*V(:,1)).*r, sin(pi*V(:,1)).*r, 3*V(:,2)];

count=renderpatch(s1);


   axis off;
   grid on
   daspect([1 1 1])
   
   light('position',[10,-10,10])
   %light('position',[10, 10, 10])
   
   %Do a persptective transform
   set(gca,'projection','perspective')
   set(gca,'CameraViewAngle',8)
   
   %The frame background color
   set(gcf,'color', [.6,.8,.8])
   xlabel('x');ylabel('y');zlabel('z'); 
   view(-40,20)
   drawnow  

rotate3d on
