/** * Note that {@code nearest} will be affected. * * @param p target point * @param nearest current nearest point to p * @param other new point to be tested * @return nearest point to p */ private static void findNearestOf(Point2D.Double p, NearestPoint nearest, Vector2d other) { double dist = p.distance(other.x, other.y); if (dist < nearest.distance) { nearest.point = other; nearest.distance = dist; } }
public static Vector2d findNearestOf(Point2D.Double p, Vector2d nearest, Vector2d other) { NearestPoint nearestPoint = new NearestPoint(); nearestPoint.point = nearest; nearestPoint.distance = p.distance(nearest.x, nearest.y); NearestVertexFinder.findNearestOf(p, nearestPoint, other); return nearest; }