function [] = slipvects2(pm,sslip,dslip,nve,faults)
%
%	 slipvects(pm,slip,nve)
%
% plots slip on fault patches on 2-D grid
%
% Input:
%	pm = patchmodel (dislocation parameters)
%	pm(:,1) = length;
%	pm(:,2) = width;
%	pm(:,3) = depth;
%	pm(:,4) = dip;
%	pm(:,5) = strike;
%	pm(:,6) = East Offset;
%	pm(:,7) = North Offset;
%	slip = slip values
%	nve  = number of vertical elements
%
% Modification of plotpatchslip2 (P. Segall) by Kaj Johnson to plot slip vectors in the fault plane 

depth=pm(:,3);

dd1=zeros(size(depth));
dd1(1:nve:end)=0*depth(1:nve:end);

for k=2:nve
   dd1(k:nve:end)=dd1(k-1:nve:end) + pm(1,2);
   
end


y = -[dd1 + pm(:,2), dd1];

x = zeros(size(y));
nhe = size(pm,1)/nve;

% for first nve elements
	x(1:nve,2) = pm(1,1);
for k=2:nhe
	index1 = nve*(k-1);
	index2 = nve*(k-2);
	x( index1+1:index1+nve , :) = ...
	[x(index2+1:index2+nve,2), ...
		 x(index2+1:index2+nve,2) + pm(index1+1,1)*ones(nve,1)];
end



%figure

%plots vectors at the center of the patch
xx=(x(:,1)+x(:,2))/2;
yy=(y(:,1)+y(:,2))/2;
quiver(xx,yy,sslip,dslip,'k'), axis('equal')
hold on


%plot fault boundaries

ax=[0 faults(1,1)];
ay=[0 0];
bx=[faults(1,1) faults(1,1)];
by=[0 -faults(1,2)];
cx=ax;
cy=[-faults(1,2) -faults(1,2)];
dx=[0 0];
dy=[0 -faults(1,2)];



plot(ax,ay,'k',bx,by,'k',cx,cy,'k',dx,dy,'k')