public Point2D checkMiddleContactForSpecificTriangle(Point2D center) { for (int i = 0; i < all.size() - 1; i++) { final Point2D.Double pt1 = all.get(i); final Point2D.Double pt2 = all.get(i + 1); final Point2D.Double middle = new Point2D.Double((pt1.getX() + pt2.getX()) / 2, (pt1.getY() + pt2.getY()) / 2); final double delta = middle.distance(center); if (delta < 1) { return all.get((i - 1) % all.size()); } } return null; }
continue; final double dist = n1.getCenter().distance(n2.getCenter()); v1.addAdjacencies(v2, dist); v2.addAdjacencies(v1, dist);
/** * Computes the alpha parameter for an ellipse curl. */ private double computeParamsEllipse(Point2D.Double pt, Point2D.Double ptNext, double r, double curlAdv) { double length = pt.distance(ptNext); if (Double.compare(length, 0.0) == 0) { return ANGLE_34_DEG; } double e = length - curlAdv; double arg = (curlAdv / 2 + e / 2) / r; return (arg < -1.0 || arg > 1.0) ? 0.0 : Math.acos(arg); }
/** * Gets the remaining path distance. * * @return distance (meters). */ private double getRemainingPathDistance() { double result = 0D; double prevXLoc = 0; double prevYLoc = 0; if (person != null) { prevXLoc = person.getXLocation(); prevYLoc = person.getYLocation(); } else if (robot != null) { prevXLoc = robot.getXLocation(); prevYLoc = robot.getYLocation(); } for (int x = walkingPathIndex; x < walkingPath.size(); x++) { Point2D nextLoc = walkingPath.get(x); double distance = Point2D.Double.distance(prevXLoc, prevYLoc, nextLoc.getX(), nextLoc.getY()); result += distance; prevXLoc = nextLoc.getX(); prevYLoc = nextLoc.getY(); } return result; }
@Override public List<MeasureItem> computeMeasurements(MeasurableLayer layer, boolean releaseEvent, Unit displayUnit) { if (layer != null && layer.hasContent() && isShapeValid()) { MeasurementsAdapter adapter = layer.getMeasurementAdapter(displayUnit); if (adapter != null) { ArrayList<MeasureItem> measVal = new ArrayList<>(3); if (LINE_LENGTH.getComputed()) { measVal.add( new MeasureItem(LINE_LENGTH, ptC.distance(ptD) * adapter.getCalibRatio(), adapter.getUnit())); } if (ORIENTATION.getComputed()) { measVal.add(new MeasureItem(ORIENTATION, MathUtil.getOrientation(ptC, ptD), Messages.getString("measure.deg"))); //$NON-NLS-1$ } if (AZIMUTH.getComputed()) { measVal.add( new MeasureItem(AZIMUTH, MathUtil.getAzimuth(ptC, ptD), Messages.getString("measure.deg"))); //$NON-NLS-1$ } return measVal; } } return Collections.emptyList(); }
/** * Gets the total path length. * @return path length (meters). */ public double getPathLength() { double result = 0D; if (pathLocations.size() > 0) { InsidePathLocation previousLocation = pathLocations.get(0); Iterator<InsidePathLocation> i = pathLocations.iterator(); while (i.hasNext()) { InsidePathLocation location = i.next(); result += Point2D.Double.distance(previousLocation.getXLocation(), previousLocation.getYLocation(), location.getXLocation(), location.getYLocation()); previousLocation = location; } } return result; }
/** * Returns a circle passing by the 3 given points. * * @param P1 the first point. * @param P2 the second point. * @param P3 the third point. * @return a circle passing by the given points. */ public static Ellipse2D circle(final Point2D P1, final Point2D P2, final Point2D P3) { final Point2D.Double center = ShapeUtilities.circleCentre(P1.getX(), P1.getY(), P2.getX(), P2.getY(), P3.getX(), P3.getY()); final double radius = center.distance(P2); return new Ellipse2D.Double(center.x - radius, center.y - radius, 2*radius, 2*radius); }
/** * Returns a circle passing by the 3 given points. * * @param P1 the first point. * @param P2 the second point. * @param P3 the third point. * @return a circle passing by the given points. */ public static Ellipse2D circle(final Point2D P1, final Point2D P2, final Point2D P3) { final Point2D.Double center = ShapeUtilities.circleCentre(P1.getX(), P1.getY(), P2.getX(), P2.getY(), P3.getX(), P3.getY()); final double radius = center.distance(P2); return new Ellipse2D.Double(center.x - radius, center.y - radius, 2*radius, 2*radius); }
public Polygon2D getPolygon2D() { Polygon2D pol = new Polygon2D(); for (int i = 0; i < npoints - 1; i++) { pol.addPoint(xpoints[i], ypoints[i]); } Point2D.Double p0 = new Point2D.Double(xpoints[0], ypoints[0]); Point2D.Double p1 = new Point2D.Double(xpoints[npoints-1], ypoints[npoints-1]); if (p0.distance(p1) > ASSUME_ZERO) pol.addPoint(xpoints[npoints-1], ypoints[npoints-1]); return pol; }
public Polygon2D getPolygon2D() { Polygon2D pol = new Polygon2D(); for (int i = 0; i < npoints - 1; i++) { pol.addPoint(xpoints[i], ypoints[i]); } Point2D.Double p0 = new Point2D.Double(xpoints[0], ypoints[0]); Point2D.Double p1 = new Point2D.Double(xpoints[npoints-1], ypoints[npoints-1]); if (p0.distance(p1) > ASSUME_ZERO) pol.addPoint(xpoints[npoints-1], ypoints[npoints-1]); return pol; }
public Polygon2D getPolygon2D() { Polygon2D pol = new Polygon2D(); for (int i = 0; i < npoints - 1; i++) { pol.addPoint(xpoints[i], ypoints[i]); } Point2D.Double p0 = new Point2D.Double(xpoints[0], ypoints[0]); Point2D.Double p1 = new Point2D.Double(xpoints[npoints-1], ypoints[npoints-1]); if (p0.distance(p1) > ASSUME_ZERO) pol.addPoint(xpoints[npoints-1], ypoints[npoints-1]); return pol; }
protected Double getPerimeter(List<Point2D.Double> handlePointList) { if (handlePointList.size() > 1) { double perimeter = 0d; Point2D.Double pLast = handlePointList.get(0); for (Point2D.Double p2 : handlePointList) { perimeter += pLast.distance(p2); pLast = p2; } return perimeter; } return null; }
/** * Converts a Cartesian-specified point to a polar-specified point. * @param point the Cartesian-specified point * @return a point whose x is the radius, y is the angle (from x-axis) of the point */ public static Point2D.Double toPolarFromCartesian(Point2D.Double point) { return new Point2D.Double(point.distance(0,0), angle(point)); }
/** * Computes magnitude of a vector. * @param vec the vector * @return magnitude */ public static double magnitude(Point2D.Double vec) { return vec.distance(0, 0); }
public static double[] getErreurs(final Point2D.Double[] _img, final Point2D.Double[] _reel, final AffineTransform _trans, final double[] _error) { if (CtuluLibArray.isEmpty(_img) || CtuluLibArray.isEmpty(_reel) || _trans == null) { return null; } final double[] res = (_error != null && _error.length == _img.length) ? _error : new double[_img.length]; final Point2D.Double tmp = new Point2D.Double(); for (int i = res.length - 1; i >= 0; i--) { _trans.transform(_img[i], tmp); res[i] = tmp.distance(_reel[i]); } return res; }
/** * Gets the distance between two points. * * @param point1 the first point. * @param point2 the second point. * @return distance (meters). */ public static double getDistance(Point2D point1, Point2D point2) { return Point2D.Double.distance(point1.getX(), point1.getY(), point2.getX(), point2.getY()); }
protected void updateTool() { Point2D ptA = getHandlePoint(0); centerPt = GeomUtil.getCircleCenter(pts); radius = (centerPt != null && ptA != null) ? centerPt.distance(ptA) : 0; } }
final double closeTestLimit = 0.05; if (size >= 2 && points.get(size - 1).distance(points.get(0)) > closeTestLimit)