function [ angle ] = angleBetweenLines( line1_x1, line1_y1, line1_x2, line1_y2, line2_x1, line2_y1, line2_x2, line2_y2 )
%ANGLEBETWEENLINES Summary of this function goes here
%   computes the angle between 2 lines

%angle = atan((line1_y2-line1_y1)/(line1_x2-line1_x1)) - atan((line2_y2-line2_y1)/(line2_x2-line2_x1));

v1 = [line1_x2, line1_y2] - [line1_x1, line1_y1]; 
v2 = [line2_x2, line2_y2] - [line2_x1, line2_y1];
angle = atan2d(norm(cross2D(v1,v2)), dot(v1,v2));  % Four-quadrant inverse tangent in degrees

    function [crossProduct] = cross2D(v1, v2)
       crossProduct = v1(1) * v2(2) - v1(2) * v2(1); 
    end

end

