Filament types code example

From Dynamo
Jump to navigation Jump to search

This code exemplifies the geometry and syntax of different filament types.

Expected onscreen result of running this code on Matlab.
% We construct a set of fake points:
points = [1:10:100;1:10:100;1:10:100]';

%%
% we create four filaments of different types

pathFilament   = dmodels.filamentWithTorsion();
helixFilament  = dmodels.filamentSubunitsInHelix();
ringFilament   = dmodels.filamentRings();
randomFilament = dmodels.filament();

% the names on the left are arbitrarily chosen variable names.
% the names on the right are the functions (actually class constructors)
%   that we are invoking

%% 

% we provide parameters for the individual geometries:

% filament with subunits on path. Radius is not required.
pathFilament.subunits_dphi = 60; % changes the x axis of successive subunits
pathFilament.subunits_dz   = 10;

% helical path of filament
helixFilament.radius        = 20;
helixFilament.subunits_dphi = 5; 
helixFilament.subunits_dz   = 1;

% rings
ringFilament.radius          = 20; % distance of subunits to center
ringFilament.ringSeparation  = 30; % distance between rings
ringFilament.subunitsPerRing = 16; % subunits on each ring

% filament: points randomly organized on the filament walls
randomFilament.radius              = 20;
randomFilament.mesh_parameter      = 15;
randomFilament.crop_mesh_parameter = 30; % a mean distance between particles of 30 pixels
    


%%
% we create a figure to depict 
figure(1);clf; 

% loops on each model

% we create a cell array variable containing all models so that we can loop on it 
f = {pathFilament,helixFilament,ringFilament,randomFilament};

for i=1:length(f);
    
    % provides the same points to each filament type
    f{i}.points = points;
    
    % creates a backbone
    f{i}.backboneUpdate();
        

    % creates the crop points
    f{i}.updateCrop();
    
    % creates a subplot for each model
    h = subplot(1,4,i); % array of 1 row and 4 columns
    
    
    f{i}.plotPoints(h,'refresh',false,'hold_limits',false);        % plots points delivered by the user
    %f{i}.plotTablePoints(h,'refresh',false,'hold_limits',false);   % plots computed table Points
    f{i}.plotTableSketch(h,'refresh',false,'hold_limits',true);   % plots computed table directions
    
    % sets as title of each plot the class of the filament 
    title(class(f{i}));
     axis(h,'equal');
    axis(h,[-20,120,-20,120,-20,120]); % visualization limits
   
    
    drawnow; % updates the plot
end

set(gcf,'Name','Filament types in Dynamo');