本文整理汇总了Java中org.apache.commons.math3.geometry.euclidean.twod.Vector2D.distance方法的典型用法代码示例。如果您正苦于以下问题:Java Vector2D.distance方法的具体用法?Java Vector2D.distance怎么用?Java Vector2D.distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.geometry.euclidean.twod.Vector2D
的用法示例。
在下文中一共展示了Vector2D.distance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getObjectiveFunctionGradient
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public ObjectiveFunctionGradient getObjectiveFunctionGradient() {
return new ObjectiveFunctionGradient(new MultivariateVectorFunction() {
public double[] value(double[] params) {
Vector2D center = new Vector2D(params[0], params[1]);
double radius = getRadius(center);
// gradient of the sum of squared residuals
double dJdX = 0;
double dJdY = 0;
for (Vector2D pk : points) {
double dk = pk.distance(center);
dJdX += (center.getX() - pk.getX()) * (dk - radius) / dk;
dJdY += (center.getY() - pk.getY()) * (dk - radius) / dk;
}
dJdX *= 2;
dJdY *= 2;
return new double[] { dJdX, dJdY };
}
});
}
示例2: getRadius
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public double getRadius(Vector2D center) {
double r = 0;
for (Vector2D point : points) {
r += point.distance(center);
}
return r / points.size();
}
示例3: getModelFunctionJacobian
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public MultivariateMatrixFunction getModelFunctionJacobian() {
return new MultivariateMatrixFunction() {
public double[][] value(double[] params) {
final int n = points.size();
final Vector2D center = new Vector2D(params[0], params[1]);
double dRdX = 0;
double dRdY = 0;
for (Vector2D pk : points) {
double dk = pk.distance(center);
dRdX += (center.getX() - pk.getX()) / dk;
dRdY += (center.getY() - pk.getY()) / dk;
}
dRdX /= n;
dRdY /= n;
// Jacobian of the radius residuals.
double[][] jacobian = new double[n][2];
for (int i = 0; i < n; i++) {
final Vector2D pi = points.get(i);
final double di = pi.distance(center);
jacobian[i][0] = (center.getX() - pi.getX()) / di - dRdX;
jacobian[i][1] = (center.getY() - pi.getY()) / di - dRdY;
}
return jacobian;
}
};
}
示例4: value
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public double value(double[] variables) {
Vector2D center = new Vector2D(variables[0], variables[1]);
double radius = getRadius(center);
double sum = 0;
for (Vector2D point : points) {
double di = point.distance(center) - radius;
sum += di * di;
}
return sum;
}
示例5: getModelFunctionJacobian
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public ModelFunctionJacobian getModelFunctionJacobian() {
return new ModelFunctionJacobian(new MultivariateMatrixFunction() {
public double[][] value(double[] params) {
final int n = points.size();
final Vector2D center = new Vector2D(params[0], params[1]);
double dRdX = 0;
double dRdY = 0;
for (Vector2D pk : points) {
double dk = pk.distance(center);
dRdX += (center.getX() - pk.getX()) / dk;
dRdY += (center.getY() - pk.getY()) / dk;
}
dRdX /= n;
dRdY /= n;
// Jacobian of the radius residuals.
double[][] jacobian = new double[n][2];
for (int i = 0; i < n; i++) {
final Vector2D pi = points.get(i);
final double di = pi.distance(center);
jacobian[i][0] = (center.getX() - pi.getX()) / di - dRdX;
jacobian[i][1] = (center.getY() - pi.getY()) / di - dRdY;
}
return jacobian;
}
});
}
示例6: getObjectiveFunction
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public ObjectiveFunction getObjectiveFunction() {
return new ObjectiveFunction(new MultivariateFunction() {
public double value(double[] params) {
Vector2D center = new Vector2D(params[0], params[1]);
double radius = getRadius(center);
double sum = 0;
for (Vector2D point : points) {
double di = point.distance(center) - radius;
sum += di * di;
}
return sum;
}
});
}