Example #1
0
 public boolean check() {
   final double width = targetState.getRobot().getWidth();
   final double height = targetState.getRobot().getHeight();
   final Rectangle targetRect =
       new Rectangle(
           (int) (targetState.getRobot().getX() - width / 2),
           (int) (targetState.getRobot().getY() - height / 2),
           (int) width,
           (int) height);
   final LXXPoint bulletPos =
       (LXXPoint)
           sourceState.project(sourceState.angleTo(targetState.getRobot()), getTraveledDistance());
   final boolean contains = targetRect.contains(bulletPos);
   if (contains) {
     final double bo = LXXUtils.bearingOffset(sourceState, targetState, targetState.getRobot());
     final double targetWidth =
         LXXUtils.getRobotWidthInRadians(sourceState, targetState.getRobot());
     final IntervalDouble currentInterval =
         new IntervalDouble(bo - targetWidth / 2, bo + targetWidth / 2);
     if (hitBearingOffsetInterval == null) {
       hitBearingOffsetInterval = currentInterval;
     } else {
       hitBearingOffsetInterval.a = min(hitBearingOffsetInterval.a, currentInterval.a);
       hitBearingOffsetInterval.b = max(hitBearingOffsetInterval.b, currentInterval.b);
     }
   }
   return contains;
 }
Example #2
0
 public double getTraveledDistance() {
   return (sourceState.getRobot().getTime() - launchTime + 1) * speed;
 }