Home > arte3.2.0 > robots > equipment > cylinders > create_cylinder.m

create_cylinder

PURPOSE ^

%%%%%%%%%%%%%%%%%

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

%%%%%%%%%%%%%%%%%
   LINK 0: BASE
%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %%%%%%%%%%%%%%%%%%
0002 %   LINK 0: BASE
0003 %%%%%%%%%%%%%%%%%%
0004 filename='link0_test.stl'; %base
0005 cyl_radius=0.025;
0006 cyl_height = 0.1;
0007 precision = 40; % increase to obtain a more accurate drawing
0008 
0009 %create a unit height cylinder with 100 points. Radius 75
0010 [X,Y,Z] = cylinder([cyl_radius], precision);
0011 %Multiply Z by height
0012 Z=Z*cyl_height;
0013 
0014 %Save in stl format, create new file
0015 surf2stl(filename, X, Y, Z, 'ascii', 'w');
0016 
0017 %now create a disk, bottom
0018 radius = linspace(0,cyl_radius,precision); % For ten rings
0019 theta = (pi/180)*[0:15:360]; % For eight angles
0020 [R,T] = meshgrid(radius,theta); % Make radius/theta grid
0021 X = R.*cos(T); % Convert grid to cartesian coordintes
0022 Y = R.*sin(T);
0023 
0024 %append this solid to already created file, bottom disk
0025 surf2stl(filename, X, Y, 0.*X, 'ascii', 'a+');
0026 %top disk
0027 surf2stl(filename, X, Y, cyl_height.*ones(size(X,1), size(X,2)), 'ascii', 'a+');

Generated on Fri 03-Jan-2014 12:20:01 by m2html © 2005