Here you can find the source of distance(float x1, float y1, float x2, float y2)
public static float distance(float x1, float y1, float x2, float y2)
//package com.java2s; /************************************************************************************** * util_tree/*ww w . j a v a 2 s .c o m*/ * Copyright (c) 2014-2017 National University of Colombia, https://github.com/remixlab * @author Jean Pierre Charalambos, http://otrolado.info/ * * All rights reserved. Library that eases the creation of interactive * scenes, released under the terms of the GNU Public License v3.0 * which is available at http://www.gnu.org/licenses/gpl.html **************************************************************************************/ public class Main { /** * @return Euclidean distance between points (x1,y1) and (x2,y2). */ public static float distance(float x1, float y1, float x2, float y2) { return (float) Math.sqrt((float) Math.pow((x2 - x1), 2.0) + (float) Math.pow((y2 - y1), 2.0)); } /** * @return Euclidean distance between points (x1,y1,z1) and (x2,y2,z2). */ public static float distance(float x1, float y1, float z1, float x2, float y2, float z2) { return (float) Math.sqrt((float) Math.pow((x2 - x1), 2.0) + (float) Math.pow((y2 - y1), 2.0) + (float) Math.pow((z2 - z1), 2.0)); } /** * @return Euclidean distance between points (x1,y1,z1,rx1,y1,rz1) and * (x2,y2,z2,rx2,y2,rz2). */ public static float distance(float x1, float y1, float z1, float rx1, float ry1, float rz1, float x2, float y2, float z2, float rx2, float ry2, float rz2) { return (float) Math.sqrt((float) Math.pow((x2 - x1), 2.0) + (float) Math.pow((y2 - y1), 2.0) + (float) Math.pow((z2 - z1), 2.0) + (float) Math.pow((rx2 - rx1), 2.0) + (float) Math.pow((ry2 - ry1), 2.0) + (float) Math.pow((rz2 - rz1), 2.0)); } }