Java Geometry Algorithm areLocationsClose(Point2D point1, Point2D point2)

Here you can find the source of areLocationsClose(Point2D point1, Point2D point2)

Description

Checks if two locations are very close together.

License

Open Source License

Parameter

Parameter Description
point1 the first point.
point2 the second point.

Return

true if very close together

Declaration

public static boolean areLocationsClose(Point2D point1, Point2D point2) 

Method Source Code

//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());
    }
}

Related

  1. applyMidPointApprox(CubicCurve2D cubic, QuadCurve2D quad)
  2. arcThroughThreePoints(float x1, float y1, float x2, float y2, float x3, float y3, boolean clockwise)
  3. area2(Point2D a, Point2D b, Point2D c)
  4. AreAlign(Point2D.Double pivot, Point2D.Double a, Point2D.Double b)
  5. areDifferentAnchorPoints(Point2D p1, Point2D p2)
  6. assertEDT(String point)
  7. botCorners(Point2D.Double p)
  8. botRect(Point2D.Double botLocation)
  9. botSides( Point2D.Double botLocation)