Implement Euclidean distance for coordinates

This commit is contained in:
2023-11-02 23:02:32 +01:00
parent 0778d4ff2e
commit 31029795d4
8 changed files with 79 additions and 2 deletions

View File

@@ -108,5 +108,15 @@ public abstract class LocationableModel extends Model implements Locationable {
return Distance.manhattan(this.coordinates, other.getCoordinates());
}
@Override
public double euclideanDistance(Vector2ic coordinates) {
return Distance.euclidean(this.coordinates.x, this.coordinates.y, coordinates.x(), coordinates.y());
}
@Override
public double euclideanDistance(Locationable other) {
return Distance.euclidean(this.coordinates.x, this.coordinates.y, other.getCoordinates().x(), other.getCoordinates().y());
}
private enum PlacingMode {BY_POSITION, BY_COORDINATES}
}