function [ p ] = translatePoint( k, p)
% This function translates points away from obstables
% 
% Input:
%            k - Kernel(to check which directions have obstables)
%            p - Given point to be translated
% Output:
%            p - Translated point
%
% Copyright (c) 2017, Rujie Wang
% All rights reserved.
%
% IN NO CIRCUMSTANCES SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
% RESPONSIBLE FOR ANY PROBLEM, DAMAGE OR LOSS CAUSED.
%
% Redistribution of this code, with or without modification, are permitted 
% provided that the above copyright and disclaimer are retained.

    dx = 2; % length to translate vertically
    dy = 2; % length to translate horizontally
    
    T = [-dy,  dx; % direction to translate
           0,  dx;
          dy,  dx;
         -dy,   0;
          dy,   0;
         -dy, -dx;
           0, -dx;
          dy, -dx];

      if ( k(1)== 0 || k(2) == 0 || k(4)== 0 )
        p = p + T(8,:);
      end
      
      if ( k(2)== 0 || k(3) == 0 || k(5)== 0 )
        p = p + T(6,:);
      end
      
      if ( k(4)== 0 || k(6) == 0 || k(7)== 0 )
        p = p + T(3,:);
      end
      
      if ( k(5)== 0 || k(7) == 0 || k(8)== 0 )
        p = p + T(1,:);
      end
end

