Example #1
0
 public Position midpoint(Position p1, Position p2) {
   return new Position((p1.getX() + p2.getX()) / 2, (p1.getY() + p2.getY()) / 2);
 }
Example #2
0
 public double distance(Position p1, Position p2) {
   return Math.sqrt(
       (p1.getX() - p2.getX()) * (p1.getX() - p2.getX())
           + (p1.getY() - p2.getY()) * (p1.getY() - p2.getY()));
 }