Here you can find the source of distance(int x1, int y1, int x2, int y2)
Parameter | Description |
---|---|
x1 | X coordinate of first point. |
y1 | Y coordinate of first point. |
x2 | X coordinate of second point. |
y2 | Y coordinate of second point. |
public static double distance(int x1, int y1, int x2, int y2)
//package com.java2s; //License from project: Open Source License public class Main { /**/*ww w. j ava 2s . co m*/ * Calculate the distance between two 2D points. * * @param x1 X coordinate of first point. * @param y1 Y coordinate of first point. * @param x2 X coordinate of second point. * @param y2 Y coordinate of second point. * * @return Distance between the two points. */ public static double distance(int x1, int y1, int x2, int y2) { double dx = x1 - x2; double dy = y1 - y2; return Math.sqrt(dx * dx + dy * dy); } }