当前位置: 首页>>代码示例>>Java>>正文


Java Vector2D.getX方法代码示例

本文整理汇总了Java中org.apache.commons.math3.geometry.euclidean.twod.Vector2D.getX方法的典型用法代码示例。如果您正苦于以下问题:Java Vector2D.getX方法的具体用法?Java Vector2D.getX怎么用?Java Vector2D.getX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.math3.geometry.euclidean.twod.Vector2D的用法示例。


在下文中一共展示了Vector2D.getX方法的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;
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:18,代码来源:MultiSteering.java

示例2: 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;
}
 
开发者ID:NOVA-Team,项目名称:NOVA-Core,代码行数:26,代码来源:ItemRenderPipeline.java

示例3: 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);
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:27,代码来源:PolyhedronsSet.java

示例4: 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;
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:24,代码来源:CircleProblem.java

示例5: 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);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:22,代码来源:OutlineExtractor.java

示例6: 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);
}
 
开发者ID:NOVA-Team,项目名称:NOVA-GUI,代码行数:14,代码来源:RelativePosition.java

示例7: getDimensions

import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
@Override
public Vector2D getDimensions() {
	double width = 0, height = 0;
	for (T text : this.text) {
		Vector2D dim = text.getDimensions();
		height = Math.max(height, dim.getY());
		width += dim.getX();
	}
	return new Vector2D(width, height);
}
 
开发者ID:NOVA-Team,项目名称:NOVA-GUI,代码行数:11,代码来源:IText.java

示例8: 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;
        }
    };
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:30,代码来源:CircleVectorial.java

示例9: 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;
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:12,代码来源:CircleProblem.java

示例10: 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;
            }
    });
}
 
开发者ID:Quanticol,项目名称:CARMA,代码行数:30,代码来源:CircleVectorial.java

示例11: 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];

    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:59,代码来源:Steering.java

示例12: asP

import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public static Point2d asP (Vector2D in) {
	return new Point2d(in.getX(), in.getY());
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:4,代码来源:Concarnie.java

示例13: RelativePosition

import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
public RelativePosition(Vector2D pos, Anchor xAnchor, Anchor yAnchor) {
	this(pos.getX(), pos.getY(), xAnchor, yAnchor);
	//xRelative = yRelative = true;
}
 
开发者ID:NOVA-Team,项目名称:NOVA-GUI,代码行数:5,代码来源:RelativePosition.java

示例14: revalidate

import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
@Override
public void revalidate(AbstractGuiContainer<?, ?> parent) {
	Outline outline = parent.getOutline();
	Vector2D dimension = outline.getDimension();

	GuiComponent<?, ?> cComp = components.get(Anchor.CENTER);
	GuiComponent<?, ?> wComp = components.get(Anchor.WEST);
	GuiComponent<?, ?> eComp = components.get(Anchor.EAST);
	GuiComponent<?, ?> nComp = components.get(Anchor.NORTH);
	GuiComponent<?, ?> sComp = components.get(Anchor.SOUTH);

	if (nComp != null) {
		setSizeOf(nComp, new Vector2D(dimension.getX(), nComp.getOutline().getHeight()));
	}
	if (sComp != null) {
		setSizeOf(sComp, new Vector2D(dimension.getX(), sComp.getOutline().getHeight()));
	}

	Vector2D nDim = getPreferredSizeOf(nComp);
	Vector2D sDim = getPreferredSizeOf(sComp);

	if (wComp != null) {
		setSizeOf(wComp, new Vector2D(wComp.getOutline().getWidth(), dimension.getY() - nDim.getY() - sDim.getY()));
	}
	if (wComp != null) {
		setSizeOf(eComp, new Vector2D(eComp.getOutline().getWidth(), dimension.getY() - nDim.getY() - sDim.getY()));
	}

	Vector2D wDim = getPreferredSizeOf(wComp);
	Vector2D eDim = getPreferredSizeOf(eComp);
	Vector2D cDim = Vector2DUtil.min(new Vector2D(dimension.getX() - wDim.getX() - eDim.getX(), dimension.getY() - nDim.getY() - sDim.getY()), getMaximumSizeOf(cComp));

	Vector2D v4 = new Vector2D(0, dimension.getY() - nDim.getY() - sDim.getY());
	wDim = Vector2DUtil.min(Vector2DUtil.max(wDim, v4), getMaximumSizeOf(wComp));
	eDim = Vector2DUtil.min(Vector2DUtil.max(eDim, v4), getMaximumSizeOf(eComp));

	Vector2D v5 = new Vector2D(dimension.getX(), 0);
	nDim = Vector2DUtil.min(Vector2DUtil.max(nDim, v5), getMaximumSizeOf(nComp));
	sDim = Vector2DUtil.min(Vector2DUtil.max(sDim, v5), getMaximumSizeOf(sComp));

	// Centers the border components
	int wOffset = (int) (nDim.getY() + (dimension.getY() - nDim.getY() - sDim.getY()) / 2 - wDim.getY() / 2);
	int eOffset = (int) (nDim.getY() + (dimension.getY() - nDim.getY() - sDim.getY()) / 2 - eDim.getY() / 2);
	int nOffset = (int) ((dimension.getX() - nDim.getX()) / 2);
	int sOffset = (int) ((dimension.getX() - sDim.getX()) / 2);

	// Center the center component
	int cOffsetX = (int) ((dimension.getX() - wDim.getX() - eDim.getX()) / 2 - cDim.getX() / 2);
	int cOffsetY = (int) ((dimension.getY() - nDim.getY() - sDim.getY()) / 2 - cDim.getY() / 2);

	setOutlineOf(cComp, new Outline(new Vector2D(wDim.getX() + cOffsetX, nDim.getY() + cOffsetY), cDim));
	setOutlineOf(wComp, new Outline(new Vector2D(0, wOffset), wDim));
	setOutlineOf(eComp, new Outline(new Vector2D(dimension.getX() - eDim.getX(), eOffset), eDim));
	setOutlineOf(nComp, new Outline(new Vector2D(nOffset, 0), nDim));
	setOutlineOf(sComp, new Outline(new Vector2D(sOffset, dimension.getY() - sDim.getY()), sDim));
}
 
开发者ID:NOVA-Team,项目名称:NOVA-GUI,代码行数:57,代码来源:BorderLayout.java

示例15: MirroredMapping

import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; //导入方法依赖的package包/类
private MirroredMapping(Vector2D firstItemOffset) {
	super(new Vector2D(
		firstItemOffset.getX() + posx[lastIngredientIndexOnFirstLine] - Arrays.stream(posx).max().orElse(0),
		firstItemOffset.getY() - posy[0]));
}
 
开发者ID:NOVA-Team,项目名称:NOVA-Core,代码行数:6,代码来源:ShapedCraftingRecipe.java


注:本文中的org.apache.commons.math3.geometry.euclidean.twod.Vector2D.getX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。