Ejemplo n.º 1
0
  public static Point2D getRandomPointAroundObj(WorldObject obj, double averageRadius) {

    double randomAngle = randomGen.nextDouble() * 2d * Math.PI;
    double randomOffset = ((randomGen.nextDouble() - 0.5d) * 0.2d) + 1d;
    double offsetY = (Math.sin(randomAngle) * averageRadius) * randomOffset;
    double offsetX = (Math.cos(randomAngle) * averageRadius) * randomOffset;

    offsetX += obj.getBounds().getCenterX();
    offsetY += obj.getBounds().getCenterY();
    return new Point2D.Double(offsetX, offsetY);
  }