add Point.distance()

This commit is contained in:
Hannes Janetzek 2014-02-07 14:13:41 +01:00
parent 91d99c0efb
commit 83d36fe04b

View File

@ -36,6 +36,14 @@ public class Point {
return y; return y;
} }
public double distance(Point other) {
return Math.sqrt((x - other.x) * (x - other.x) + (y - other.y) + (y - other.y));
}
public double distanceSq(Point other) {
return (x - other.x) * (x - other.x) + (y - other.y) + (y - other.y);
}
@Override @Override
public String toString() { public String toString() {
return x + " " + y; return x + " " + y;