本文整理汇总了Java中org.apache.harmony.awt.gl.Crossing.solveQuad方法的典型用法代码示例。如果您正苦于以下问题:Java Crossing.solveQuad方法的具体用法?Java Crossing.solveQuad怎么用?Java Crossing.solveQuad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.harmony.awt.gl.Crossing
的用法示例。
在下文中一共展示了Crossing.solveQuad方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: intersectLineAndQuad
import org.apache.harmony.awt.gl.Crossing; //导入方法依赖的package包/类
/**
* It checks up if there is intersection of the line (x1, y1) - (x2, y2) and
* the quad curve (qx1, qy1) - (qx2, qy2) - (qx3, qy3). The parameters of the intersection
* area saved to params array. Therefore the params size must be at learst 4.
* @return The method returns the quantity of roots lied in the defined interval
*/
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;
}
示例2: intersectLineAndQuad
import org.apache.harmony.awt.gl.Crossing; //导入方法依赖的package包/类
/**
* It checks up if there is intersection of the line (x1, y1) - (x2, y2) and
* the quad curve (qx1, qy1) - (qx2, qy2) - (qx3, qy3). The parameters of
* the intersection area saved to params array. Therefore the params size
* must be at learst 4.
*
* @return The method returns the quantity of roots lied in the defined
* interval
*/
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;
}
示例3: solveQuadratic
import org.apache.harmony.awt.gl.Crossing; //导入方法依赖的package包/类
public static int solveQuadratic(double eqn[], double res[]) {
return Crossing.solveQuad(eqn, res);
}
示例4: solveQuadratic
import org.apache.harmony.awt.gl.Crossing; //导入方法依赖的package包/类
public static int solveQuadratic(double eqn[], double res[]) {
return Crossing.solveQuad(eqn, res);
}
示例5: solveQuadratic
import org.apache.harmony.awt.gl.Crossing; //导入方法依赖的package包/类
/**
* Finds the roots of the quadratic polynomial. This is accomplished by
* finding the (real) values of x that solve the following equation:
* eqn[2]*x*x + eqn[1]*x + eqn[0] = 0. The solutions are written into the
* array res starting from the index 0 in the array. The return value tells
* how many array elements have been written by this method call.
*
* @param eqn
* an array containing the coefficients of the quadratic
* polynomial to solve.
* @param res
* the array that this method writes the results into.
* @return the number of roots of the quadratic polynomial.
* @throws ArrayIndexOutOfBoundsException
* if {@code eqn.length} < 3 or if {@code res.length} is less
* than the number of roots.
* @throws NullPointerException
* if either array is null.
*/
public static int solveQuadratic(double eqn[], double res[]) {
return Crossing.solveQuad(eqn, res);
}