Here you can find the source of areLocationsClose(Point2D point1, Point2D point2)
Parameter | Description |
---|---|
point1 | the first point. |
point2 | the second point. |
public static boolean areLocationsClose(Point2D point1, Point2D point2)
//package com.java2s; //License from project: Open Source License import java.awt.geom.Point2D; public class Main { /** A very small distance (meters) for measuring how close two locations are. */ private static final double VERY_SMALL_DISTANCE = .00001D; /**/*w w w. j av a 2s.c o m*/ * Checks if two locations are very close together. * * @param point1 the first point. * @param point2 the second point. * @return true if very close together */ public static boolean areLocationsClose(Point2D point1, Point2D point2) { double distance = getDistance(point1, point2); return (distance < VERY_SMALL_DISTANCE); } /** * 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()); } }