本文整理汇总了Java中org.openimaj.math.geometry.point.Point2d.getX方法的典型用法代码示例。如果您正苦于以下问题:Java Point2d.getX方法的具体用法?Java Point2d.getX怎么用?Java Point2d.getX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openimaj.math.geometry.point.Point2d
的用法示例。
在下文中一共展示了Point2d.getX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isInside
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
@Override
public boolean isInside(Point2d point) {
// Unrotate the point relative to the center of the ellipse
final double cosrot = Math.cos(-rotation);
final double sinrot = Math.sin(-rotation);
final double relx = (point.getX() - x);
final double rely = (point.getY() - y);
final double xt = cosrot * relx - sinrot * rely;
final double yt = sinrot * relx + cosrot * rely;
final double ratiox = xt / major;
final double ratioy = yt / minor;
return ratiox * ratiox + ratioy * ratioy <= 1;
}
示例2: value
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
RealVector value(double[] params) {
final double[] result = new double[data.size()];
for (int i = 0; i < data.size(); i++) {
final IndependentPair<? extends Point2d, ? extends Point2d> pair = data.get(i);
final Point2d p1 = pair.firstObject();
final Point2d p2 = pair.secondObject();
final double x = p1.getX();
final double y = p1.getY();
final double X = p2.getX();
final double Y = p2.getY();
result[i] = computeValue(x, y, X, Y, params[0], params[1], params[2], params[3], params[4], params[5],
params[6], params[7]);
}
return new ArrayRealVector(result, false);
}
示例3: calculateError
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
* Compute the average per-pixel error (in pixels)
*
* @return the average per-pixel error
*/
public double calculateError() {
double error = 0;
int nPoints = 0;
for (int i = 0; i < points.size(); i++) {
for (int j = 0; j < points.get(i).size(); j++) {
nPoints++;
final Point2d model = points.get(i).get(j).firstObject();
final Point2d observed = points.get(i).get(j).secondObject();
final Point2d predicted = cameras.get(i).project(model);
final float dx = observed.getX() - predicted.getX();
final float dy = observed.getY() - predicted.getY();
error += Math.sqrt(dx * dx + dy * dy);
}
}
return error / nPoints;
}
示例4: isInside
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
@Override
public final boolean isInside(Point2d point) {
final float v1x = vertices[0].getX();
final float v1y = vertices[0].getY();
final float v2x = vertices[1].getX();
final float v2y = vertices[1].getY();
final float v3x = vertices[2].getX();
final float v3y = vertices[2].getY();
final float px = point.getX();
final float py = point.getY();
if (px > v1x && px > v2x && px > v3x)
return false;
if (px < v1x && px < v2x && px < v3x)
return false;
if (py > v1y && py > v2y && py > v3y)
return false;
if (py < v1y && py < v2y && py < v3y)
return false;
final int o1 = getOrientation(v1x, v1y, v2x, v2y, px, py);
final int o2 = getOrientation(v2x, v2y, v3x, v3y, px, py);
final int o3 = getOrientation(v3x, v3y, v1x, v1y, px, py);
return (o1 == o2) && (o2 == o3);
}
示例5: buildDataMatrix
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
private Matrix buildDataMatrix(List<PointList> data) {
final int nData = data.size();
final int nPoints = data.get(0).size();
final Matrix m = new Matrix(nData, nPoints * 2);
final double[][] mData = m.getArray();
for (int i = 0; i < nData; i++) {
final PointList pts = data.get(i);
for (int j = 0, k = 0; k < nPoints; j += 2, k++) {
final Point2d pt = pts.points.get(k);
mData[i][j] = pt.getX();
mData[i][j + 1] = pt.getY();
}
}
return m;
}
示例6: jacobian
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
RealMatrix jacobian(double[] params) {
final double[][] result = new double[data.size()][];
for (int i = 0; i < data.size(); i++) {
final IndependentPair<? extends Point2d, ? extends Point2d> pair = data.get(i);
final Point2d p1 = pair.firstObject();
final Point2d p2 = pair.secondObject();
final double x = p1.getX();
final double y = p1.getY();
final double X = p2.getX();
final double Y = p2.getY();
result[i] = computeJacobian(x, y, X, Y, params[0], params[1], params[2], params[3], params[4], params[5],
params[6], params[7]);
}
return new Array2DRowRealMatrix(result, false);
}
示例7: maxXY
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
private Point2dImpl maxXY(PointList newCurve) {
float maxX = Float.MIN_VALUE;
float maxY = Float.MIN_VALUE;
for (Point2d point2d : newCurve) {
float px = point2d.getX();
float py = point2d.getY();
maxX = Math.max(px, maxX);
maxY = Math.max(py, maxY);
}
return new Point2dImpl(maxX,maxY);
}
示例8: reflectAroundLine
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
* Reflects a point around a this line.
*
* @param pointToReflect
* The point to reflect
* @return The reflected point
*
* @see "http://algorithmist.wordpress.com/2009/09/15/reflecting-a-point-about-a-line/"
*/
public Point2d reflectAroundLine(Point2d pointToReflect) {
double nx = end.getX() - begin.getX();
double ny = end.getY() - begin.getY();
final double d = Math.sqrt(nx * nx + ny * ny);
nx /= d;
ny /= d;
final double px = pointToReflect.getX() - begin.getX();
final double py = pointToReflect.getY() - begin.getY();
final double w = nx * px + ny * py;
final double rx = 2 * begin.getX() - pointToReflect.getX() + 2 * w * nx;
final double ry = 2 * begin.getY() - pointToReflect.getY() + 2 * w * ny;
return new Point2dImpl((float) rx, (float) ry);
}
示例9: isConvex
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
* Test if the outer polygon is convex.
*
* @return true if the outer polygon is convex; false if non-convex or less
* than two vertices
*/
@Override
public boolean isConvex() {
final boolean isOriginallyClosed = this.isClosed();
if (isOriginallyClosed)
this.open();
final int size = size();
if (size < 3)
return false;
float res = 0;
for (int i = 0; i < size; i++) {
final Point2d p = points.get(i);
final Point2d tmp = points.get((i + 1) % size);
final Point2dImpl v = new Point2dImpl();
v.x = tmp.getX() - p.getX();
v.y = tmp.getY() - p.getY();
final Point2d u = points.get((i + 2) % size);
if (i == 0) // in first loop direction is unknown, so save it in res
res = u.getX() * v.y - u.getY() * v.x + v.x * p.getY() - v.y * p.getX();
else {
final float newres = u.getX() * v.y - u.getY() * v.x + v.x * p.getY() - v.y * p.getX();
if ((newres > 0 && res < 0) || (newres < 0 && res > 0))
return false;
}
}
if (isOriginallyClosed)
close();
return true;
}
示例10: fundamentalMatrix8PtNorm
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
* The normalised 8-point algorithm for estimating the Fundamental matrix
*
* @param data
* @return the estimated Fundamental matrix
*/
public static Matrix fundamentalMatrix8PtNorm(List<? extends IndependentPair<Point2d, Point2d>> data) {
Matrix A;
final Pair<Matrix> normalisations = getNormalisations(data);
A = new Matrix(data.size(), 9);
for (int i = 0; i < data.size(); i++) {
final Point2d p1 = data.get(i).firstObject().transform(normalisations.firstObject());
final Point2d p2 = data.get(i).secondObject().transform(normalisations.secondObject());
final float x1_1 = p1.getX(); // u
final float x1_2 = p1.getY(); // v
final float x2_1 = p2.getX(); // u'
final float x2_2 = p2.getY(); // v'
A.set(i, 0, x2_1 * x1_1); // u' * u
A.set(i, 1, x2_1 * x1_2); // u' * v
A.set(i, 2, x2_1); // u'
A.set(i, 3, x2_2 * x1_1); // v' * u
A.set(i, 4, x2_2 * x1_2); // v' * v
A.set(i, 5, x2_2); // v'
A.set(i, 6, x1_1); // u
A.set(i, 7, x1_2); // v
A.set(i, 8, 1); // 1
}
final double[] W = MatrixUtils.solveHomogeneousSystem(A);
Matrix fundamental = new Matrix(3, 3);
fundamental.set(0, 0, W[0]);
fundamental.set(0, 1, W[1]);
fundamental.set(0, 2, W[2]);
fundamental.set(1, 0, W[3]);
fundamental.set(1, 1, W[4]);
fundamental.set(1, 2, W[5]);
fundamental.set(2, 0, W[6]);
fundamental.set(2, 1, W[7]);
fundamental.set(2, 2, W[8]);
fundamental = MatrixUtils.reduceRank(fundamental, 2);
fundamental = normalisations.secondObject().transpose().times(fundamental).times(normalisations.firstObject());
return fundamental;
}
示例11: circumCircle
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
private static boolean circumCircle(Point2d p, Triangle t, Circle circle) {
float m1, m2, mx1, mx2, my1, my2;
float dx, dy, rsqr, drsqr;
/* Check for coincident points */
if (Math.abs(t.firstVertex().getY() - t.secondVertex().getY()) < EPSILON
&& Math.abs(t.secondVertex().getY() - t.thirdVertex().getY()) < EPSILON)
{
System.err.println("CircumCircle: Points are coincident.");
return false;
}
if (Math.abs(t.secondVertex().getY() - t.firstVertex().getY()) < EPSILON) {
m2 = -(t.thirdVertex().getX() - t.secondVertex().getX()) / (t.thirdVertex().getY() - t.secondVertex().getY());
mx2 = (t.secondVertex().getX() + t.thirdVertex().getX()) / 2.0f;
my2 = (t.secondVertex().getY() + t.thirdVertex().getY()) / 2.0f;
circle.setX((t.secondVertex().getX() + t.firstVertex().getX()) / 2.0f);
circle.setY(m2 * (circle.getX() - mx2) + my2);
}
else if (Math.abs(t.thirdVertex().getY() - t.secondVertex().getY()) < EPSILON) {
m1 = -(t.secondVertex().getX() - t.firstVertex().getX()) / (t.secondVertex().getY() - t.firstVertex().getY());
mx1 = (t.firstVertex().getX() + t.secondVertex().getX()) / 2.0f;
my1 = (t.firstVertex().getY() + t.secondVertex().getY()) / 2.0f;
circle.setX((t.thirdVertex().getX() + t.secondVertex().getX()) / 2.0f);
circle.setY(m1 * (circle.getX() - mx1) + my1);
}
else {
m1 = -(t.secondVertex().getX() - t.firstVertex().getX()) / (t.secondVertex().getY() - t.firstVertex().getY());
m2 = -(t.thirdVertex().getX() - t.secondVertex().getX()) / (t.thirdVertex().getY() - t.secondVertex().getY());
mx1 = (t.firstVertex().getX() + t.secondVertex().getX()) / 2.0f;
mx2 = (t.secondVertex().getX() + t.thirdVertex().getX()) / 2.0f;
my1 = (t.firstVertex().getY() + t.secondVertex().getY()) / 2.0f;
my2 = (t.secondVertex().getY() + t.thirdVertex().getY()) / 2.0f;
circle.setX((m1 * mx1 - m2 * mx2 + my2 - my1) / (m1 - m2));
circle.setY(m1 * (circle.getX() - mx1) + my1);
}
dx = t.secondVertex().getX() - circle.getX();
dy = t.secondVertex().getY() - circle.getY();
rsqr = dx * dx + dy * dy;
circle.setRadius((float) Math.sqrt(rsqr));
dx = p.getX() - circle.getX();
dy = p.getY() - circle.getY();
drsqr = dx * dx + dy * dy;
return drsqr <= rsqr;
}
示例12: ComparablePoint
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
public ComparablePoint(Point2d pt) {
this.x = pt.getX();
this.y = pt.getY();
}
示例13: transformTouch
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
@Override
public Touch transformTouch(Touch point){
int distortion_iterations = 5; // From OpenCV
double x, y, x0, y0;
double cx = cameraMatrix.get(0,2);
double cy = cameraMatrix.get(1,2);
double fx = cameraMatrix.get(0,0) / 10;
double fy = cameraMatrix.get(1,1) / 10;
double ifx = 1/fx;
double ify = 1/fy;
float k1 = distortion[0] ;
float k2 = distortion[1];
float p1 = distortion[2];
float p2 = distortion[3];
float k3 = distortion[4];
float k4 = distortion[5];
float k5 = distortion[6];
float k6 = distortion[7];
x = point.getX();
y = point.getY();
x0 = x = (x - cx)*ifx;
y0 = y = (y - cy)*ify;
// compensate distortion iteratively
for( int j = 0; j < distortion_iterations; j++ )
{
double r2 = x*x + y*y;
double icdist = (1 + ((k6*r2 + k5)*r2 + k4)*r2)/(1 + ((k3*r2 + k2)*r2 + k1)*r2);
double deltaX = 2*p1*x*y + p2*(r2 + 2*x*x);
double deltaY = p1*(r2 + 2*y*y) + 2*p2*x*y;
x = (x0 - deltaX)*icdist;
y = (y0 - deltaY)*icdist;
}
point.setX((float) x);
point.setY((float) y);
point.translate((float)cx, (float)cy);
Point2d newc = point.calculateCentroid().transform(homography);
return new Touch(newc.getX(),newc.getY(),point.getRadius(), point.touchID, point.motionVector);
}
示例14: distance
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
private int distance(Point2d p1, Point2d p2) {
final double dx = p1.getX() - p2.getX();
final double dy = p1.getY() - p2.getY();
return (int) Math.sqrt(dx * dx + dy * dy);
}
示例15: beforeAxesRender
import org.openimaj.math.geometry.point.Point2d; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*
* @see org.openimaj.vis.general.XYPlotVisualisation#beforeAxesRender(org.openimaj.image.MBFImage,
* org.openimaj.vis.general.AxesRenderer2D)
*/
@Override
synchronized public void beforeAxesRender(final MBFImage visImage,
final AxesRenderer2D<Float[], MBFImage> axesRenderer)
{
synchronized (axesRenderer)
{
// Redraw the world if the image dimensions aren't the same.
if (this.cachedWorldImage == null ||
visImage.getWidth() != this.cachedWorldImage.getWidth() ||
visImage.getHeight() != this.cachedWorldImage.getHeight())
this.drawCachedImage(visImage, axesRenderer);
// Blat the cached image
System.out.println("Blitting cached world image");
visImage.drawImage(this.cachedWorldImage, 0, 0);
// Make the image fit into the axes centred around 0,0 long/lat
final Point2d mid = axesRenderer.calculatePosition(0, 0);
final Point2d dateLine0 = axesRenderer.calculatePosition(180, 0);
final Point2d northPole = axesRenderer.calculatePosition(0, -90);
final double scaleX = (dateLine0.getX() - mid.getX()) / 180d;
final double scaleY = (northPole.getY() - mid.getY()) / 90d;
Matrix trans = Matrix.identity(3, 3);
trans = trans.times(
TransformUtilities.scaleMatrixAboutPoint(
scaleX, -scaleY, mid
)
);
// Translate to 0,0
trans = trans.times(
TransformUtilities.translateMatrix(mid.getX(), mid.getY())
);
// Now draw the countries onto the sea. We transform each of the
// shapes
// by the above transform matrix prior to plotting them to the
// image.
final HashSet<String> k = new HashSet<String>(this.activeCountries);
for (final String countryCode : k)
{
final WorldPlace wp = this.worldPolys.byCountryCode(countryCode);
// Each place may have more than one polygon.
final List<Shape> shapes = wp.getShapes();
final MBFImageRenderer ir = visImage.createRenderer(RenderHints.ANTI_ALIASED);
// For each of the polygons... draw them to the image.
for (Shape s : shapes)
{
s = s.transform(trans);
// Draw the country in the highlight colour
final Float[] col = this.countryHighlightColours.get(wp.getISOA2());
ir.drawShapeFilled(s, col == null ? this.highlightCountryLandColour : col);
// Draw the outline shape of the country
ir.drawShape(s, 1, this.defaultCountryOutlineColour);
}
}
}
}