add Point.distance()
This commit is contained in:
parent
91d99c0efb
commit
83d36fe04b
@ -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;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user