function plotfall( A, Locations, support, bar ) 
% PLOTFALL   Plot the modes in which the truss is not stable. 
% 
%  Alex Townsend, April 2015 


nmodes = size(A,2) - size(A,1);     
% pad A with some zeros; 
B = [ A ; zeros(nmodes,size(A,2)) ]; 

[U, S, V] = svd( B );       
idx = find( diag(S) < 1e-14 ); % Number of mechanism + rigid body movements
s = diag(S); 
modes = V(:,idx); 

%% Add in zeros for supported pins: 
for j = 1:numel(support)
    modes = [ modes( 1:2*support(j)-2, : ) ; ... 
                zeros(2,numel(idx)); 
              modes(  2*support(j)-1:size(modes,1),:) ]; 
end

% Do some tricks to make the subplot look better: 
p = factor(numel(idx)); 
if ( numel( p ) > 2 || numel(p) < 2 ) 
    p = [1, prod(p)];
end

% For each unstable displacement, plot a new figure with that displacement:
NewLocations = Locations; 
for each = 1:numel(idx) 
    mx = max( abs(s(each)*modes(:,each)) );
    subplot(p(1),p(2),each)
    plottrussdashed( Locations, support, bar)
    NewLocations(:,1) = Locations(:,1) + .1/mx*s(each)*modes(1:2:end,each); 
    NewLocations(:,2) = Locations(:,2) + .1/mx*s(each)*modes(2:2:end,each); 
    plottruss( NewLocations, support, bar)
    title( ' UNSTABLE ', 'fontsize', 16 )   % Tell me the truss is unstable
end

% If the truss is stable, then say so: 
if ( numel( idx ) == 0 ) 
    plottruss( Locations, support, bar)
    title( ' STABLE ', 'fontsize', 16 )
end

end