Home > arte3.2.0 > robots > example > 1dofplanar > 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 %Multiply Z by height
0012 Z=Z*2*cyl_height-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+');
0028 
0029 
0030 %%%%%%%%%%%%%%%%%%
0031 %   LINK 1
0032 %%%%%%%%%%%%%%%%%%
0033 filename='link1.stl'; 
0034 cyl_radius=0.05;
0035 cyl_height = 1;
0036 precision = 20; % increase to obtain a more accurate drawing
0037 
0038 %create a unit height cylinder with 100 points. Radius 75
0039 [Z,Y,X] = cylinder([cyl_radius], precision);
0040 %Multiply Z by height
0041 X=-X*cyl_height;
0042 
0043 %Save in stl format, create new file
0044 surf2stl(filename, X, Y, Z, 'ascii', 'w');
0045 
0046 
0047 %%%%%%%%%%%%%%%%%%
0048 %   LINK 2
0049 %%%%%%%%%%%%%%%%%%
0050 filename='link2.stl';
0051 cyl_radius=0.05;
0052 cyl_height = 1;
0053 precision = 20; % increase to obtain a more accurate drawing
0054 
0055 %create a unit height cylinder with 100 points. Radius 75
0056 [Z,Y,X] = cylinder([cyl_radius], precision);
0057 %Multiply Z by height
0058 X=-X*cyl_height;
0059 
0060 %Save in stl format, create new file
0061 surf2stl(filename, X, Y, Z, 'ascii', 'w');

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