-1
I have a class Ponto
:
public class Ponto {
public int x;
public int y;
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
}
I have to create a "distance" method that takes another instance per parameter and calculates the Euclidean distance between the encapsulated point and the point passed by argument.
How do you calculate Euclidean distance:
Be the points A=(Xa, Ya) B=(Xb, Yb)
then the distance is
d² = (Xa-Xb)² + (Ya-Yb)²
Isolating:
d = root ( (Xa-Xb)² + (Ya-Yb)² )
Problem: how do I calculate this in the algorithm?
you are struggling at some point in specific to your code? you already have the formula, already have everything, just implement
– Math