Java Code Examples for java.awt.geom.QuadCurve2D#solveQuadratic()

The following examples show how to use java.awt.geom.QuadCurve2D#solveQuadratic() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Order3.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
 
Example 2
Source File: Order3.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
 
Example 3
Source File: Order3.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double[] ret) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
 
Example 4
Source File: Order3X.java    From pumpernickel with MIT License 6 votes vote down vote up
public static int getHorizontalParams(double c0, double cp0, double cp1,
		double c1, double ret[]) {
	if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
		return 0;
	}
	c1 -= cp1;
	cp1 -= cp0;
	cp0 -= c0;
	ret[0] = cp0;
	ret[1] = (cp1 - cp0) * 2;
	ret[2] = (c1 - cp1 - cp1 + cp0);
	int numroots = QuadCurve2D.solveQuadratic(ret, ret);
	int j = 0;
	for (int i = 0; i < numroots; i++) {
		double t = ret[i];
		// No splits at t==0 and t==1
		if (t > 0 && t < 1) {
			if (j < i) {
				ret[j] = t;
			}
			j++;
		}
	}
	return j;
}
 
Example 5
Source File: Order3.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
 
Example 6
Source File: Order3.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
 
Example 7
Source File: Order3.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
 
Example 8
Source File: Order3.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
 
Example 9
Source File: Order3.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        double t = eqn[i];
        if (t > 0 && t < 1) {
            r.add(XforT(t), YforT(t));
        }
    }
    r.add(x1, y1);
}
 
Example 10
Source File: Order3.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        double t = eqn[i];
        if (t > 0 && t < 1) {
            r.add(XforT(t), YforT(t));
        }
    }
    r.add(x1, y1);
}
 
Example 11
Source File: Order3.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public double nextVertical(double t0, double t1) {
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        if (eqn[i] > t0 && eqn[i] < t1) {
            t1 = eqn[i];
        }
    }
    return t1;
}
 
Example 12
Source File: Order3.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        double t = eqn[i];
        if (t > 0 && t < 1) {
            r.add(XforT(t), YforT(t));
        }
    }
    r.add(x1, y1);
}
 
Example 13
Source File: Order3.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        double t = eqn[i];
        if (t > 0 && t < 1) {
            r.add(XforT(t), YforT(t));
        }
    }
    r.add(x1, y1);
}
 
Example 14
Source File: Order3.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public double nextVertical(double t0, double t1) {
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        if (eqn[i] > t0 && eqn[i] < t1) {
            t1 = eqn[i];
        }
    }
    return t1;
}
 
Example 15
Source File: Order3.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        double t = eqn[i];
        if (t > 0 && t < 1) {
            r.add(XforT(t), YforT(t));
        }
    }
    r.add(x1, y1);
}
 
Example 16
Source File: Order3.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double[] eqn = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        double t = eqn[i];
        if (t > 0 && t < 1) {
            r.add(XforT(t), YforT(t));
        }
    }
    r.add(x1, y1);
}
 
Example 17
Source File: Order3.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public double nextVertical(double t0, double t1) {
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        if (eqn[i] > t0 && eqn[i] < t1) {
            t1 = eqn[i];
        }
    }
    return t1;
}
 
Example 18
Source File: Order3X.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public double nextVertical(double t0, double t1) {
	double eqn[] = { xcoeff1, 2 * xcoeff2, 3 * xcoeff3 };
	int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
	for (int i = 0; i < numroots; i++) {
		if (eqn[i] > t0 && eqn[i] < t1) {
			t1 = eqn[i];
		}
	}
	return t1;
}
 
Example 19
Source File: Order3.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        double t = eqn[i];
        if (t > 0 && t < 1) {
            r.add(XforT(t), YforT(t));
        }
    }
    r.add(x1, y1);
}
 
Example 20
Source File: Order3.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public double nextVertical(double t0, double t1) {
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        if (eqn[i] > t0 && eqn[i] < t1) {
            t1 = eqn[i];
        }
    }
    return t1;
}