public static boolean doLinesIntersect(float x1, float y1, 
                                           float x2, float y2, 
                                           float x3, float y3, 
                                           float x4, float y4) {
        double denom = (y4-y3)*(x2-x1) - (x4-x3)*(y2-y1);
        
        if (denom == 0.0) {
            // Lines do not intersect
            return false;
        }
        
        double ua = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / denom;
        double ub = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / denom;
        
        if (ua <= 1 && ua >= 0 && ub <= 1 && ub >= 0)
            return true;
        return false;
    }