Example #1
0
  /**
   * @param p another point
   * @return the distance between this point and {@code p}
   */
  protected int getDistance(Point p) {
    int[] pos = p.getPosition();

    int distX = pos[0] - this.posX;
    int distY = pos[1] - this.posY;

    return (int) Math.sqrt(Math.pow(distX, 2) + Math.pow(distY, 2));
  }
Example #2
0
 /**
  * Calculates the distance to another point along the y-axis.
  *
  * @param p the other point
  * @return the y-component distance between this point and {@code p}
  */
 protected int getDistanceY(Point p) {
   int[] pos = p.getPosition();
   return pos[1] - this.posY;
 }
Example #3
0
 /**
  * Calculates the distance to another point along the x-axis.
  *
  * @param p the other point
  * @return the x-component distance between this point and {@code p}
  */
 protected int getDistanceX(Point p) {
   int[] pos = p.getPosition();
   return pos[0] - this.posX;
 }