
function C = k12_shift_count(L1,L2,n1,n2,len,hgt,D)

% This program computes k12-counts for k12_shift in (len x hgt) box
% Here it is assumed that L1 is being shifted. L2 is a tiled version
% of the original pop 2, here referred to as "pop 2"

% Written by: TONY E. SMITH, 2/21/07

% INPUTS:
%     (i)   L1,L2   = locations,(xi,yi), of pops 1 and 2
%     (ii)  n1,n2   = sizes of pops 1 and 2
%     (iii) len,hgt = box size
%     (iv)   D  = vector of distance values (ordered low to high)

% NOTE: It is assumed that max(D) <= min{len,hgt}/2 so that counts
%       are well defined

% OUTPUTS: C = dim(D) vector of k12-counts

%random shift of pop 1

l_max = len/2; %maximum x-shift 

h_max = hgt/2; %maximum y-shift
  
num = rand(1,1);

sx = (2*l_max)*num - l_max; %x-shift

num = rand(1,1);

sy = (2*h_max)*num - h_max; %y-shift

L1 = [L1(:,1) + sx, L1(:,2) + sy]; %shifted version of L1


%Compute pairwise distances

Counts = point_counts(L1,L2,D);

%Compute Output

C = sum(Counts) ; %sum columns of Counts to get total counts


   

   
       

