public static int intersectQuads(double x1, double y1, double x2, double y2,
                                     double x3, double y3, double qx1, double qy1,
                                     double qx2, double qy2, double qx3, double qy3,
                                     double[] params) {
 
    	double[] initParams = new double[2];
        double[] xCoefs1 = new double[3];
    	double[] yCoefs1 = new double[3];
    	double[] xCoefs2 = new double[3];
    	double[] yCoefs2 = new double[3];
    	int quantity = 0;
    	
    	xCoefs1[0] = x1 - 2 * x2 + x3;
    	xCoefs1[1] = - 2 * x1 + 2 * x2;
    	xCoefs1[2] = x1;
    	
    	yCoefs1[0] = y1 - 2 * y2 + y3;
    	yCoefs1[1] = - 2 * y1 + 2 * y2;
    	yCoefs1[2] = y1;
    	
    	xCoefs2[0] = qx1 - 2 * qx2 + qx3;
    	xCoefs2[1] = - 2 * qx1 + 2 * qx2;
    	xCoefs2[2] = qx1;
    	
    	yCoefs2[0] = qy1 - 2 * qy2 + qy3;
    	yCoefs2[1] = - 2 * qy1 + 2 * qy2;
    	yCoefs2[2] = qy1;
    	
    	// initialize params[0] and params[1]
        params[0] = params[1] = 0.25;
        quadNewton(xCoefs1, yCoefs1, xCoefs2, yCoefs2, initParams);
    	if (initParams[0] <= 1 && initParams[0] >= 0 &&
                initParams[1] >=0 && initParams[1] <=1) {
            params[2 * quantity] = initParams[0];
            params[2 * quantity + 1] = initParams[1];
            ++quantity;
        }
    	// initialize params
        params[0] = params[1] = 0.75;
        quadNewton(xCoefs1, yCoefs1, xCoefs2, yCoefs2, params);
            	if (initParams[0] <= 1 && initParams[0] >= 0 &&
                initParams[1] >=0 && initParams[1] <=1) {
            params[2 * quantity] = initParams[0];
            params[2 * quantity + 1] = initParams[1];
            ++quantity;
        }

        return quantity;
    }