function [line_yes_no] = line_elem_intersect(element_nodes_x,...
    element_nodes_y, polyline_xy)
%Determines which elements are intersected by given polyline
%   Detailed explanation goes here

[elem_count,~] = size(element_nodes_x);
line_yes_no = zeros(elem_count,1);

line_x = polyline_xy(:,1);
line_y = polyline_xy(:,2);

for i = 1:elem_count
    
    side_count = element_nodes_x(i,3);
    
    for j = 1:side_count
        elem_x(j,1) = element_nodes_x(i,j+3);
        elem_y(j,1) = element_nodes_y(i,j+3);
    end
    
    elem_x(side_count+1,1) = element_nodes_x(i,4);
    elem_y(side_count+1,1) = element_nodes_y(i,4);
    
    [xi,~] = polyxpoly(line_x,line_y,elem_x,elem_y);
    [intersect_pts,~] = size(xi);
    
    if intersect_pts >= 2
        line_yes_no(i,1) = 1;
    end
    
    clear elem_x elem_y side_count intersect_pts
    
end     

end

