function fixed_stroke = fix_acer_tablet_stroke(stroke)
% Fix the stroke so that there are no repeating x,y positions or 
% timestamps. This function may result in uneven timestamps after repeating
% x,y removal. Starts each stroke with timestamp 0.

k = length(stroke);

% Doing the time interpolation
tmp_stroke(:,[1,2]) = stroke(:,[1,2]);
tmp_stroke(:,3) = [0:k-1]'*((stroke(k,3)-stroke(1,3))/k);
%tmp_stroke(:,3) = [0:k-1]'*((stroke(k,3)-stroke(1,3))/k)+ stroke(1,3);

% Doing the repeating x,y removal 
 last_point        = tmp_stroke(1,:);
 fixed_stroke(1,:) = tmp_stroke(1,:);
 index      = 1;
 for i=2:1:length(tmp_stroke);
     if ( tmp_stroke(i,[1,2]) ~= last_point([1,2]) )
         last_point            = tmp_stroke(i,:);
         fixed_stroke(index,:) = tmp_stroke(i,:);
         index = index+1;
     end
 end