BattleField { public Point2D.Double translateToField(Point2D.Double p) { return new Point2D.Double(DiaUtils.limit(18, p.x, width - 18), DiaUtils.limit(18, p.y, height - 18)); } BattleField(double width, double height); Point2D.Double translateToField(Point2D.Double p); double orbitalWallDistance(Point2D.Double sourceLocation,
      Point2D.Double targetLocation, double bulletPower, int direction); double directToWallDistance(Point2D.Double targetLocation,
      double distance, double heading, double bulletPower); double wallSmoothing(Point2D.Double startLocation, double startAngle,
      int orientation, double wallStick); final Rectangle2D.Double rectangle; final double width; final double height; }
@Test public void testTranslateToFieldEast() { BattleField battleField = newBattleField(800, 600); Double p = battleField.translateToField(newLocation(835, 300)); assertEquals(782, p.x, 0.0001); assertEquals(300, p.y, 0.0001); }
@Test public void testTranslateToFieldWest() { BattleField battleField = newBattleField(800, 600); Double p = battleField.translateToField(newLocation(-99, 300)); assertEquals(18, p.x, 0.0001); assertEquals(300, p.y, 0.0001); }
@Test public void testTranslateToFieldNorth() { BattleField battleField = newBattleField(800, 600); Double p = battleField.translateToField(newLocation(300, 650)); assertEquals(300, p.x, 0.0001); assertEquals(582, p.y, 0.0001); }
@Test public void testTranslateToFieldSouth() { BattleField battleField = newBattleField(800, 600); Double p = battleField.translateToField(newLocation(300, 9)); assertEquals(300, p.x, 0.0001); assertEquals(18, p.y, 0.0001); }
@Test public void testTranslateToFieldNorthEast() { BattleField battleField = newBattleField(800, 600); Double p = battleField.translateToField(newLocation(850, 650)); assertEquals(782, p.x, 0.0001); assertEquals(582, p.y, 0.0001); }
@Test public void testTranslateToFieldSouthEast() { BattleField battleField = newBattleField(800, 600); Double p = battleField.translateToField(newLocation(850, -828)); assertEquals(782, p.x, 0.0001); assertEquals(18, p.y, 0.0001); }
@Test public void testTranslateToFieldSouthWest() { BattleField battleField = newBattleField(800, 600); Double p = battleField.translateToField(newLocation(-98, -828)); assertEquals(18, p.x, 0.0001); assertEquals(18, p.y, 0.0001); }
@Test public void testTranslateToFieldNorthWest() { BattleField battleField = newBattleField(800, 600); Double p = battleField.translateToField(newLocation(-8828, 599)); assertEquals(18, p.x, 0.0001); assertEquals(582, p.y, 0.0001); }