Java examples for java.lang:Math Geometry Distance
Calculates the distance between two points using Pythagoras.
//package com.java2s; public class Main { /**/*from ww w. j a va 2s. co m*/ * Calculates the distance between two points using Pythagoras. * * @param a * The first point, potentially an x distance. * @param b * The second point, potentially a y distance. * @return Returns the "c" value, the hypotenuse that these two points * create. */ public static double getHypotenuse(double a, double b) { return Math.sqrt(Math.pow(Math.abs(a), 2) + Math.pow(Math.abs(b), 2)); } }