| [x,y,z,xd,zd]=rotasurf(xd,zd,th,nth,noplot)
|
function [x,y,z,xd,zd]=rotasurf(xd,zd,th,nth,noplot)
% [x,y,z,xd,zd]=rotasurf(xd,zd,th,nth,noplot)
% This function generates points on a surface of
% of revolution generated by rotating an area in
% the (x,z) plane about the z-axis
%
% xd,yz - coordinate data for the curve in the
% (x,y) which forms the cross-section
% th - [ThetaMin,ThetaMax] defining limits of
% rotation angle about the z-axis
% nth - number of theta values used to generate
% surface values
% noplot - option given any value if no plot is
% desired. Otherwise omit this value.
% x,y,z - arrays of points on the surface
%
% User m functions called: none
%----------------------------------------------
if nargin==0
n1=9; t1=-pi:pi/n1:0; n2=6; t2=0:pi/n2:pi;
Zd=[0,exp(i*t1),1/2+i+exp(i*t2)/2,0];
xd=real(Zd)+4; zd=imag(Zd);
th=[-pi/2,pi]; nth=31;
end
xd=xd(:); zd=zd(:); nd=length(xd);
t=linspace(th(1),th(2),nth);
x=xd*cos(t); y=xd*sin(t); z=repmat(zd,1,nth);
if nargin==5, return; end
close; surf(x,y,z), title('VOLUME OF REVOLUTION')
xlabel('x axis'), ylabel('y axis')
zlabel('z axis'), colormap([1 1 1]); hold on
fill3(x(:,1),y(:,1),z(:,1),'w')
fill3(x(:,end),y(:,end),z(:,end),'w')
axis equal, grid on, hold off, shg
|
|