%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
nel_micro =  6;  % number of microtubules (tension & compression)
nel_actin = 24;  % number of actin and intermediate filaments (tension)
node = 12;       % number of nodes
nel  = nel_micro + nel_actin; 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% cell coordinates %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
L0 = 1.0;        % microtubules length
s0 = L0/2;       % microtubules distance

q0=[-s0/2;  0; -L0/2; 
    -s0/2;  0; +L0/2; 
    +s0/2;  0; -L0/2; 
    +s0/2;  0; +L0/2; 
    -L0/2; -s0/2;  0; 
    +L0/2; -s0/2;  0; 
    -L0/2; +s0/2;  0; 
    +L0/2; +s0/2;  0; 
	 0; -L0/2; -s0/2;
	 0; +L0/2; -s0/2; 
	 0; -L0/2; +s0/2; 
	 0; +L0/2; +s0/2];	  	
%%% cell coordinates %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% cell elements %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% microtubules
el( 1,:) = [  1  2 ];
el( 2,:) = [  3  4 ];
el( 3,:) = [  5  6 ];
el( 4,:) = [  7  8 ];
el( 5,:) = [  9 10 ];
el( 6,:) = [ 11 12 ];

% intremediate filaments 
el( 7,:) = [  1  5 ];
el( 8,:) = [  1  7 ];
el( 9,:) = [  1  9 ];
el(10,:) = [  1 10 ];

el(11,:) = [  2  5 ];
el(12,:) = [  2  7 ];
el(13,:) = [  2 11 ];
el(14,:) = [  2 12 ];

el(15,:) = [  3  6 ];
el(16,:) = [  3  8 ];
el(17,:) = [  3  9 ];
el(18,:) = [  3 10 ];

el(19,:) = [  4  6 ];
el(20,:) = [  4  8 ];
el(21,:) = [  4 11 ];
el(22,:) = [  4 12 ];

el(23,:) = [  5  9 ];
el(24,:) = [  5 11 ];
el(25,:) = [  6  9 ];
el(26,:) = [  6 11 ];

el(27,:) = [  7 10 ];
el(28,:) = [  7 12 ];
el(29,:) = [  8 10 ];
el(30,:) = [  8 12 ];

%%% cell elements %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% plot cell  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:nel
 edof(i,1)=i;
 for j=1:2
  ic1=3*j-1; ic2=3*j; ic3=3*j+1;
  edof(i,ic1)=el(i,j)*3-2;
  edof(i,ic2)=el(i,j)*3-1;
  edof(i,ic3)=el(i,j)*3;
 end
end

t=edof(:,2:7);
for i = 1:nel
    e_mat(i,1:6)=q0(t(i,:))';
end

figure(1); clf; set(gcf, 'renderer','zbuffer'); hold on; view(114,5);

indx=[1;4];  X=e_mat(:,indx)';  Xc=[X; X(1,:)];
indx=[2;5];  Y=e_mat(:,indx)';  Yc=[Y; Y(1,:)];
indx=[3;6];  Z=e_mat(:,indx)';  Zc=[Z; Z(1,:)]; 

%%% plot microtubules %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for ie=1:nel_micro
  color=[ 1.0; 0.0; 0.0 ]; width=10; 
% color=[ 0.5; 0.5; 0.5 ]; width=10; 
    h=plot3(Xc(:,ie),Yc(:,ie),Zc(:,ie),'LineWidth',width,'Color',color);  
end
%%% plot filaments %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for ie=(nel_micro+1):nel
  color=[ 0.0; 0.0; 1.0 ]; width= 5;  
% color=[ 0.0; 0.0; 0.0 ]; width= 4; 
h=plot3(Xc(:,ie),Yc(:,ie),Zc(:,ie),'LineWidth',width,'Color',color);  
end

axis off; axis image;		
print('-depsc', '-r200',  ['cell01']);	
hold off
%%% plot cell  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
