Java Distance between Points getDistance(Point2D point1, Point2D point2)

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

Description

Gets the distance between two points.

License

Open Source License

Parameter

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

Return

distance (meters).

Declaration

public static double getDistance(Point2D point1, Point2D point2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.geom.Point2D;

public class Main {
    /**//w  w w .j av  a  2  s.co m
     * 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. distance(@Nonnull Point2D pA, @Nonnull Point2D pB)
  2. distance(final double p1X, final double p1Y, final double p2X, final double p2Y)
  3. distance(Point2D a, Point2D b)
  4. DistanceSquareToLine(double x, double y, double x1, double y1, double x2, double y2)
  5. getDistance(Point2D point1, Point2D point2)
  6. getDistance(Point2D.Double pt1, Point2D.Double pt2)