public static int intersectLineAndQuad(double x1, double y1, double x2, double y2,
                                           double qx1, double qy1, double qx2, double qy2, 
                                           double qx3, double qy3, double[] params) {
        double[] eqn = new double[3];
        double[] t = new double[2];
        double[] s = new double[2];
        double dy = y2 - y1;
        double dx = x2 - x1;
        int quantity = 0;
        int count = 0;

        eqn[0] = dy * (qx1 - x1) - dx * (qy1 - y1);
        eqn[1] = 2 * dy * (qx2 - qx1) - 2 * dx * (qy2 - qy1);
        eqn[2] = dy * (qx1 - 2 * qx2 + qx3) - dx *(qy1 -2 * qy2 + qy3);
        
        if ((count = Crossing.solveQuad(eqn, t)) == 0) {
            return 0;
        }

        for (int i = 0; i < count; i++) {
            if (dx != 0) {
                s[i] = (quad(t[i], qx1, qx2, qx3) - x1) / dx;
            } else if (dy != 0) {
                s[i] = (quad(t[i], qy1, qy2, qy3) - y1) / dy;
            } else {
            	s[i] = 0.0;
            }
            if (t[i] >= 0 && t[i] <= 1 && s[i] >= 0 && s[i] <= 1) {
                params[2 * quantity] = t[i];
                params[2 * quantity + 1] = s[i];
                ++quantity;
            }
        }

        return quantity;
    }