% Input:
% k1,t1,k2,t2: double (defining the equations y1 = k1x + t1 and y2 = k2x +
% t2)

% Output:
% x: 2x1 vector

% Description:
% Computes the intersection between two 2-dimensional lines

function [x] = intersectLines(k1,t1,k2,t2)

x = [inf;inf];
if k1 == k2
    fprintf('Cannot1 compute intersection of parallel lines !\n');
else
    
    if k2 == Inf || k2 == -Inf
        
        if k1 == Inf || k1 == -Inf
            %both lines are vertical -> may not occure
            display('Cannot1 compute intersection of parallel lines !\n');
            x = [Inf; Inf];
        else
            %1st line is vertical
            x = [-k1 1;1 0]\[t1 ;t2];
        end;
        
    else  
        if k1 ==Inf || k1 == -Inf
            %2nd line is vertical
            x = [1 0;-k2 1]\[t1 ;t2];
        else
            %no line is vertical
            x = [-k1 1; -k2 1]\[t1 ;t2];
        end;      
    end;
 
end;