Exemple #1
0
  public boolean isInTheWay(Point from, Point to, Point obstacle, int size) {

    double a = from.distance(obstacle);
    double b = to.distance(obstacle);

    double dist = from.distance(to);

    if (a < dist && b < dist) {
      return Line2D.ptLineDist(from.x, from.y, to.x, to.y, obstacle.x, obstacle.y) < size;
    }
    return false;
  }
Exemple #2
0
 public boolean inShape(int mx, int my) {
   if (type == 1) {
     if (mx >= x && mx <= x + W && my >= y && my <= y + H) {
       return true;
     } else {
       return false;
     }
   } else if (type == 2) {
     return Math.sqrt((mx - x) * (mx - x) + (my - y) * (my - y)) < W;
   } else {
     return (Line2D.ptLineDist(sX, sY, eX, eY, mx, my) < 7);
   }
 }
Exemple #3
0
 boolean pointInLine(Point p, int fx, int fy, int tx, int ty) {
   double d =
       Line2D.ptLineDist(
           (double) fx, (double) fy, (double) tx, (double) ty, (double) p.x, (double) p.y);
   return d <= 6.0;
 }