You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: ray_polygon_intersect.m
    path of file: ./repos/gptoolbox/mesh
    
    the code of the file until where you have to start completion: function [flag, t, lambda, S] = ray_polygon_intersect(o,d,V,E)
% RAY_POLYGON_INTERSECT 2D Ray/polygon intersection
% 
% [flag, t, lambda] = ray_polygon_intersect(o,d,V,E)
%
% Input:
%    o  2D vector ray origin.
%    d  2D vector ray direction.
%    V  #V by 2 list of vertex positions
%    E  #E by 2 list of edge indices
% Output:
%    flag  #E list of bools: (false) Reject, (true) Intersect.
%    t  #E list of distances from the ray origin.
%    lambda  #E list of parameter of hit between E(:,1) and E(:,2)
%    S  #E by #o list of signs
%

  epsilon = eps;%0.00001;

  assert(size(V,2) == 2);

    
function [flag, t, lambda, S] = ray_polygon_intersect(o,d,V,E)
% RAY_POLYGON_INTERSECT 2D Ray/polygon intersection
% 
% [flag, t, lambda] = ray_polygon_intersect(o,d,V,E)
%
% Input:
%    o  2D vector ray origin.
%    d  2D vector ray direction.
%    V  #V by 2 list of vertex positions
%    E  #E by 2 list of edge indices
% Output:
%    flag  #E list of bools: (false) Reject, (true) Intersect.
%    t  #E list of distances from the ray origin.
%    lambda  #E list of parameter of hit between E(:,1) and E(:,2)
%    S  #E by #o list of signs
%

  epsilon = eps;%0.00001;

  assert(size(V,2) == 2);
  assert(size(E,2) == 2);
  % number of edges 
  m = size(E,1);
  %assert(numel(d) == 2);

  
  p1 = V(E(:,1),:);
  p2 = V(E(:,2),:);
  % edge vectors from 1 to 2
  e12 = p2-p1;
  % perpend