List of utility methods to do Distance between Point and Line
double | distanceFromLine(int xa, int ya, int xb, int yb, int xc, int yc) distance From Line int xdiff = xb - xa; int ydiff = yb - ya; long l2 = (long) (xdiff * xdiff + ydiff * ydiff); if (l2 == 0L) { return (double) length(xa, ya, xc, yc); } else { double rnum = (double) ((ya - yc) * (ya - yb) - (xa - xc) * (xb - xa)); double r = rnum / (double) l2; ... |
double | distancePointToBot(Point2D.Double sourceLocation, Point2D.Double botLocation) distance Point To Bot if (sourceLocation.x > botLocation.x - 18 && sourceLocation.x < botLocation.x + 18 && sourceLocation.y > botLocation.y - 18 && sourceLocation.y < botLocation.y + 18) { return 0; } else { ArrayList<Line2D.Double> botSides = new ArrayList<Line2D.Double>(); botSides.add(new Line2D.Double(botLocation.x - 18, botLocation.y - 18, botLocation.x + 18, botLocation.y - 18)); botSides.add(new Line2D.Double(botLocation.x + 18, botLocation.y - 18, botLocation.x + 18, ... |
double | distancePointToLine(final Point2D point, final Line2D line) Given a line based on two points, and a point away from the line, find the perpendicular distance from the point to the line. final Point2D l1 = line.getP1(); final Point2D l2 = line.getP2(); return Math .abs((l2.getX() - l1.getX()) * (l1.getY() - point.getY()) - (l1.getX() - point.getX()) * (l2.getY() - l1.getY())) / Math.sqrt(Math.pow(l2.getX() - l1.getX(), 2) + Math.pow(l2.getY() - l1.getY(), 2)); |
double | DistanceToLine(double x, double y, double x1, double y1, double x2, double y2) Distance To Line return Math.sqrt(DistanceSquareToLine(x, y, x1, y1, x2, y2));
|
double | distanceToLine(Point2D p, Point2D endA, Point2D endZ) Computes distance from a point on a plane to line given by two points. double AC = p.distance(endA); double BC = p.distance(endZ); double AB = endA.distance(endZ); if (AB == (AC + BC)) { return 0; double ACs = AC * AC; double BCs = BC * BC; ... |
double | distanceToLine2(Line2D l, Point2D p) distance To Line Point2D p2 = nearestPointOnLine(l, p, true, null);
return p.distance(p2);
|
double | distanceToLine3(Line2D l, Point2D p) distance To Line double dDist = 0; if (l.getX1() == l.getX2()) dDist = p.getX() - l.getX1(); else if (l.getY1() == l.getY2()) dDist = p.getY() - l.getY1(); else { double dM1 = ((double) l.getY2() - l.getY1()) / ((double) l.getX2() - l.getX1()); double dB1 = l.getY1() - (dM1 * l.getX1()); ... |
double | getDistance(double aX, double aY, double bX, double bY) get Distance return Math.abs(Math.sqrt(Math.pow(aX - bX, 2) + Math.pow(aY - bY, 2)));
|
Double | getDistance(Line2D aSegment, Point aPoint) get Distance double lenght1 = getLineLength(aSegment.getX1(), aSegment.getY1(), aPoint.getX(), aPoint.getY()); double lenght2 = getLineLength(aSegment.getX2(), aSegment.getY2(), aPoint.getX(), aPoint.getY()); return new Double(lenght1 + lenght2); |
double | getDistanceToCenter(Point2D p, Line2D line) get Distance To Center Point2D midPoint = new Point2D.Double((line.getP1().getX() + line.getP2().getX()) / 2, (line.getP1().getY() + line.getP2().getY()) / 2); return Math.hypot(midPoint.getX() - p.getX(), midPoint.getY() - p.getY()); |