Home > arte3.2.0 > robots > example > 3dofplanar > create_links_stl.m

create_links_stl

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.stl'; %base
0005 cyl_radius=0.05;
0006 cyl_height = 0.1;
0007 precision = 20; % 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 
0012 %Multiply Z by height
0013 Z=Z*2*cyl_height-cyl_height;
0014 
0015 %Save in stl format, create new file
0016 surf2stl(filename, X, Y, Z, 'ascii', 'w');
0017 
0018 %now create a disk, bottom
0019 radius = linspace(0,cyl_radius,precision); % For ten rings
0020 theta = (pi/180)*[0:15:360]; % For eight angles
0021 [R,T] = meshgrid(radius,theta); % Make radius/theta grid
0022 X = R.*cos(T); % Convert grid to cartesian coordintes
0023 Y = R.*sin(T);
0024 
0025 %append this solid to already created file, bottom disk
0026 surf2stl(filename, X, Y, 0.*X, 'ascii', 'a+');
0027 %top disk
0028 surf2stl(filename, X, Y, cyl_height.*ones(size(X,1), size(X,2)), 'ascii', 'a+');
0029 
0030 
0031 
0032 %%%%%%%%%%%%%%%%%%
0033 %   LINK 1
0034 %%%%%%%%%%%%%%%%%%
0035 filename='link1.stl'; 
0036 cyl_radius=0.05;
0037 cyl_height = 1;
0038 precision = 20; % increase to obtain a more accurate drawing
0039 
0040 %create a unit height cylinder with 100 points. Radius 75
0041 [Z,Y,X] = cylinder([cyl_radius], precision);
0042 %Multiply Z by height
0043 X=-X*cyl_height;
0044 
0045 %Save in stl format, create new file
0046 surf2stl(filename, X, Y, Z, 'ascii', 'w');
0047 
0048 
0049 %%%%%%%%%%%%%%%%%%
0050 %   LINK 2
0051 %%%%%%%%%%%%%%%%%%
0052 filename='link2.stl';
0053 cyl_radius=0.05;
0054 cyl_height = 1;
0055 precision = 20; % increase to obtain a more accurate drawing
0056 
0057 %create a unit height cylinder with 100 points. Radius 75
0058 [Z,Y,X] = cylinder([cyl_radius], precision);
0059 %Multiply Z by height
0060 X=-X*cyl_height;
0061 
0062 %Save in stl format, create new file
0063 surf2stl(filename, X, Y, Z, 'ascii', 'w');
0064 
0065 
0066 %%%%%%%%%%%%%%%%%%
0067 %   LINK 3
0068 %%%%%%%%%%%%%%%%%%
0069 filename='link3.stl';
0070 cyl_radius=0.05;
0071 cyl_height = 1;
0072 precision = 20; % increase to obtain a more accurate drawing
0073 
0074 %create a unit height cylinder with 100 points. Radius 75
0075 [Z,Y,X] = cylinder([cyl_radius], precision);
0076 %Multiply Z by height
0077 X=-X*cyl_height;
0078 
0079 %Save in stl format, create new file
0080 surf2stl(filename, X, Y, Z, 'ascii', 'w');

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