Description: [X,Y,Z]=polyrevolve(x,z,n)
This function revolves a 2D polygon around the Z-axis. It copies the 2D data points evenly around the axis and produces a 3D data set suitable for input to MESHGRID and GRIDDATA to create a 3D surface. Useful to convert 2D axisymmetric data to 3D surfaces for presentation and or analysis. The spacing from one revolved point to the next is defined by the parameter n. The required angular spacing (alpha) for each point is determined using the relationship n=2*r*sin(alpha).
%% EXAMPLE: clear all; close all; clc; x=0:0.2:2*pi; z=sin(x+(pi/2)); revolve_res=0.2; [X,Y,Z]=polyrevolve(x,z,revolve_res); grid_res=0.05; [XI,YI] = meshgrid(min(min(X)):grid_res:max(max(X)),min(min(Y)):grid_res:max(max(Y))); ZI = griddata(X,Y,Z,XI,YI,'cubic'); figure; fig=gcf; clf(fig); units=get(fig,'units'); set(fig,'units','normalized','outerposition',[0 0 1 1]); set(fig,'units',units); plot(x,z,'r-'); hold on; axis equal; xlabel('x (mm)'); ylabel('z (mm)'); title('The polygon'); xlabel('x (mm)'); ylabel('z (mm)'); figure; fig=gcf; clf(fig); units=get(fig,'units'); set(fig,'units','normalized','outerposition',[0 0 1 1]); set(fig,'units',units); plot3(X,Y,Z,'k.'); hold on; axis equal; title('Data "copied" around z-axis using POLYREVOLVE'); xlabel('x (mm)'); ylabel('y (mm)'); zlabel('z (mm)'); figure; fig=gcf; clf(fig); units=get(fig,'units'); set(fig,'units','normalized','outerposition',[0 0 1 1]); set(fig,'units',units); surf(XI,YI,ZI,'EdgeColor','none'); hold on; axis equal; shading interp; material shiny; lightangle(45,30); title('Surface fit of the revolved data points'); xlabel('x (mm)'); ylabel('y (mm)'); zlabel('z (mm)'); License: Shareware Related: setfig units units, units dgetfig units, clffig, plotxz, Equal, mm039, xlabel, fig dgcf, figure, dsinx bpi O/S:BSD, Linux, Solaris, Mac OS X File Size: 10.0 KB Downloads: 4
|
|