本文整理汇总了Java中org.apache.commons.math3.geometry.euclidean.twod.Vector2D.getY方法的典型用法代码示例。如果您正苦于以下问题:Java Vector2D.getY方法的具体用法?Java Vector2D.getY怎么用?Java Vector2D.getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.geometry.euclidean.twod.Vector2D
的用法示例。
在下文中一共展示了Vector2D.getY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toDegrees
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public static double toDegrees(Vector2D tempSum ) {
double tempTangent = Math.abs(tempSum.getY().doubleValue()) / Math.abs(tempSum.getX().doubleValue());
double tempDegrees = Math.toDegrees(Math.atan(tempTangent));
if (tempSum.getX() >= 0 && tempSum.getY() >= 0) {
tempDegrees += 0.0;
} else if (tempSum.getX() <= 0 && tempSum.getY() >= 0) {
tempDegrees += 90.0;
} else if (tempSum.getX() <= 0 && tempSum.getY() <= 0) {
tempDegrees += 180.0;
} else if (tempSum.getX() >= 0 && tempSum.getY() <= 0) {
tempDegrees += 270.0;
}
return tempDegrees;
}
示例2: apply
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
/** {@inheritDoc} */
public SubHyperplane<Euclidean2D> apply(final SubHyperplane<Euclidean2D> sub,
final Hyperplane<Euclidean3D> original,
final Hyperplane<Euclidean3D> transformed) {
if (original != cachedOriginal) {
// we have changed hyperplane, reset the in-hyperplane transform
final Plane oPlane = (Plane) original;
final Plane tPlane = (Plane) transformed;
final Vector3D p00 = oPlane.getOrigin();
final Vector3D p10 = oPlane.toSpace((Point<Euclidean2D>) new Vector2D(1.0, 0.0));
final Vector3D p01 = oPlane.toSpace((Point<Euclidean2D>) new Vector2D(0.0, 1.0));
final Vector2D tP00 = tPlane.toSubSpace((Point<Euclidean3D>) apply(p00));
final Vector2D tP10 = tPlane.toSubSpace((Point<Euclidean3D>) apply(p10));
final Vector2D tP01 = tPlane.toSubSpace((Point<Euclidean3D>) apply(p01));
final AffineTransform at =
new AffineTransform(tP10.getX() - tP00.getX(), tP10.getY() - tP00.getY(),
tP01.getX() - tP00.getX(), tP01.getY() - tP00.getY(),
tP00.getX(), tP00.getY());
cachedOriginal = (Plane) original;
cachedTransform = org.apache.commons.math3.geometry.euclidean.twod.Line.getTransform(at);
}
return ((SubLine) sub).applyTransform(cachedTransform);
}
示例3: value
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public double[] value(double[] params) {
final double cx = params[0];
final double cy = params[1];
final double r = params[2];
final double[] model = new double[points.size() * 2];
for (int i = 0; i < points.size(); i++) {
final Vector2D p = points.get(i);
// Find the circle point closest to the observed point
// (observed points are points add through the addPoint method above)
final double dX = cx - p.getX();
final double dY = cy - p.getY();
final double scaling = r / FastMath.hypot(dX, dY);
final int index = i * 2;
model[index] = cx - scaling * dX;
model[index + 1] = cy - scaling * dY;
}
return model;
}
示例4: 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 };
}
});
}
示例5: draw
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public MeshModel draw(MeshModel model) {
Vector2D size = this.size.get();
double minX = -size.getX() / 2;
double minY = -size.getY() / 2;
double minZ = -0.5 / 16;
double maxX = size.getX() / 2;
double maxY = size.getY() / 2;
double maxZ = 0.5 / 16;
Color color = colorMultiplier.get();
Optional<Texture> texture = this.texture.get();
Face face;
Set<Face> faces;
face = drawFront(model, minX, minY, minZ, maxX, maxY, maxZ, texture);
face.vertices.forEach(v -> v.color = color);
face = drawBack(model, minX, minY, minZ, maxX, maxY, maxZ, texture);
face.vertices.forEach(v -> v.color = color);
faces = drawUpAndDown(model, minX, minY, minZ, maxX, maxY, maxZ, texture);
faces.stream().flatMap(f -> f.vertices.stream()).forEach(v -> v.color = color);
faces = drawLeftAndRight(model, minX, minY, minZ, maxX, maxY, maxZ, texture);
faces.stream().flatMap(f -> f.vertices.stream()).forEach(v -> v.color = color);
return model;
}
示例6: pointIsBetween
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
/** Check if a point is geometrically between its neighbor in an array.
* <p>The neighbors are computed considering the array is a loop
* (i.e. point at index (n-1) is before point at index 0)</p>
* @param loop points array
* @param n number of points to consider in the array
* @param i index of the point to check (must be between 0 and n-1)
* @return true if the point is exactly between its neighbors
*/
private boolean pointIsBetween(final Vector2D[] loop, final int n, final int i) {
final Vector2D previous = loop[(i + n - 1) % n];
final Vector2D current = loop[i];
final Vector2D next = loop[(i + 1) % n];
final double dx1 = current.getX() - previous.getX();
final double dy1 = current.getY() - previous.getY();
final double dx2 = next.getX() - current.getX();
final double dy2 = next.getY() - current.getY();
final double cross = dx1 * dy2 - dx2 * dy1;
final double dot = dx1 * dx2 + dy1 * dy2;
final double d1d2 = FastMath.sqrt((dx1 * dx1 + dy1 * dy1) * (dx2 * dx2 + dy2 * dy2));
return (FastMath.abs(cross) <= (1.0e-6 * d1d2)) && (dot >= 0.0);
}
示例7: getPositionOf
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public Vector2D getPositionOf(Vector2D parentSize) {
int x = xRelative ? (int) (parentSize.getX() * xOffset) : (int) xOffset;
int y = yRelative ? (int) (parentSize.getY() * yOffset) : (int) yOffset;
if (xAnchor == Anchor.EAST) {
x = (int) parentSize.getX() - x;
}
if (yAnchor == Anchor.SOUTH) {
y = (int) parentSize.getY() - y;
}
return new Vector2D(x, y);
}
示例8: createDimensions
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
protected void createDimensions() {
double width = 0, height = 0;
for (IText t2 : lines) {
Vector2D dim = t2.getDimensions();
width = Math.max(height, dim.getX());
height += dim.getY();
}
dimensions = new Vector2D(width, height);
}
示例9: setWorldAndResolution
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
@Override
public void setWorldAndResolution(Minecraft mc, int width, int height) {
ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
MCCanvas canvas = new MCCanvas(width, height, Tessellator.getInstance(), scaledresolution.getScaleFactor());
if (textRenderer == null) {
textRenderer = new MCTextRenderer(fontRendererObj, canvas);
}
textRenderer.setCanvas(canvas);
graphics = new Graphics(canvas, textRenderer);
boolean resized = width != outline.getWidth() || height != outline.getHeight();
Outline oldOutline = outline;
outline = new Outline(0, 0, width, height);
if (resized) {
Optional<Vector2D> preferredSize = getComponent().getPreferredSize();
if (preferredSize.isPresent()) {
// Set the size to the preferred size and center the GUI
Vector2D size = preferredSize.get();
int xOffset = (int) (width / 2 - size.getX() / 2);
int yOffset = (int) (height / 2 - size.getY() / 2);
setOutline(getOutline().setPosition(new Vector2D(xOffset, yOffset)).setDimension(size));
}
onResized(oldOutline);
}
xSize = outline.getWidth();
ySize = outline.getHeight();
super.setWorldAndResolution(mc, width, height);
}
示例10: setWorldAndResolution
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
@Override
public void setWorldAndResolution(Minecraft mc, int width, int height) {
ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
fontRendererObj = mc.fontRenderer;
MCCanvas canvas = new MCCanvas(width, height, Tessellator.instance, scaledresolution.getScaleFactor());
if (textRenderer == null) {
textRenderer = new MCTextRenderer(fontRendererObj, canvas);
}
textRenderer.setCanvas(canvas);
graphics = new Graphics(canvas, textRenderer);
boolean resized = width != outline.getWidth() || height != outline.getHeight();
Outline oldOutline = outline;
outline = new Outline(0, 0, width, height);
if (resized) {
Optional<Vector2D> preferredSize = getComponent().getPreferredSize();
if (preferredSize.isPresent()) {
// Set the size to the preferred size and center the GUI
Vector2D size = preferredSize.get();
int xOffset = (int) (width / 2 - size.getX() / 2);
int yOffset = (int) (height / 2 - size.getY() / 2);
setOutline(getOutline().setPosition(new Vector2D(xOffset, yOffset)).setDimension(size));
}
onResized(oldOutline);
}
xSize = outline.getWidth();
ySize = outline.getHeight();
super.setWorldAndResolution(mc, width, height);
}
示例11: 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;
}
};
}
示例12: target
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public double[] target() {
final double[] t = new double[points.size() * 2];
for (int i = 0; i < points.size(); i++) {
final Vector2D p = points.get(i);
final int index = i * 2;
t[index] = p.getX();
t[index + 1] = p.getY();
}
return t;
}
示例13: 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;
}
});
}
示例14: run
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public VoltTable run() {
voltQueueSQL(getCurrentLocation);
VoltTable i[] = voltExecuteSQL();
Double lat = i[0].fetchRow(0).getDouble("c_lat");
Double lon = i[0].fetchRow(0).getDouble("c_lon");
Integer month = new Integer( (int) i[0].fetchRow(0).getLong("c_month"));
// Double a = SeaflowUtil.roundToHalf(lon);
// Double b = SeaflowUtil.roundToHalf(lat);
int k = 3;
List<Double> mult = new ArrayList<>();
List<Vector2D> vect = new ArrayList<>();
voltQueueSQL(getTemperatureStrip, lon-k, lat+k, lon-k, lat+k, month);
VoltTable v = voltExecuteSQL()[0];
for(int j=0; j < v.getRowCount(); j++) {
VoltTableRow row = v.fetchRow(j);
Double thisLat = row.getDouble("a_lat");
Double thisLon = row.getDouble("a_lon");
Double thisTemp = row.getDouble("a_temp");
if(row.wasNull())
continue;
if(thisLon != lon && thisLat != lat) {
vect.add( new Vector2D( 1 / (thisLon - lon), 1 / ( thisLat - lat)) );
mult.add( thisTemp );
}
}
Vector2D sum = new Vector2D(mult, vect);
double tangent = Math.abs(sum.getY().doubleValue()) / Math.abs(sum.getX().doubleValue());
double degrees = Math.toDegrees(Math.atan(tangent));
if (sum.getX() >= 0 && sum.getY() >= 0) {
degrees += 0.0;
} else if (sum.getX() <= 0 && sum.getY() >= 0) {
degrees += 90.0;
} else if (sum.getX() <= 0 && sum.getY() <= 0) {
degrees += 180.0;
} else if(sum.getX() >= 0 && sum.getY() <= 0) {
degrees += 270.0;
}
voltQueueSQL(updateSteering, degrees);
voltQueueSQL(getSteering);
VoltTable result[] = voltExecuteSQL();
return result[1];
}
示例15: asP
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public static Point2d asP (Vector2D in) {
return new Point2d(in.getX(), in.getY());
}