calculates the euclidean distance between points A and B - Java 2D Graphics

Java examples for 2D Graphics:Point

Description

calculates the euclidean distance between points A and B

Demo Code


import static java.lang.Math.pow;
import static java.lang.Math.sqrt;

public class Main{
    /**/*from ww  w  . ja v a  2s  .co  m*/
     * calculates the euclidean distance between points A and B
     * @param pointA first point
     * @param pointB second point
     * @return distance between points
     */
    public static double distance(final Point pointA, final Point pointB) {
        return sqrt(pow(pointA.getLatitude() - pointB.getLatitude(), 2)
                + pow(pointA.getLongitude() - pointB.getLongitude(), 2));
    }
}

Related Tutorials