Java tutorial
//package com.java2s; /* * wardrive4 - android wardriving application (remake for the ICS) * Copyright (C) 2012 Raffaele Ragni * https://github.com/raffaeleragni/android-wardrive4 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Computes distance between points in any dimension. * * @param p0 point 0 * @param p1 point 1 * * @return distance between points */ private static Double distance(double[] p0, double[] p1) { // Must be of same dimension if (p0.length != p1.length) return null; // Calculate distance double val = 0; for (int n = 0; n < p0.length; n++) val += Math.pow(p1[n] - p0[n], 2); return Math.sqrt(val); } }