@Test public void testOrbitalWallDistance() { BattleField battleField = newBattleField(800, 600); double wallDistance = battleField.orbitalWallDistance( newLocation(400, 100), newLocation(400, 300), 2.0, 1); assertEquals(2.0, wallDistance, 0.0001); }
public double orbitalWallDistance(Point2D.Double sourceLocation, Point2D.Double targetLocation, double bulletPower, int direction) { double absBearing = DiaUtils.absoluteBearing(sourceLocation, targetLocation); double distance = sourceLocation.distance(targetLocation); double maxEscapeAngle = Math.asin(8.0/(20-3.0*bulletPower)); double wallDistance = 2.0; for (int x = 0; x < 200; x++) { if (!rectangle.contains( sourceLocation.x + (Math.sin(absBearing + (direction*(x/100.0)*maxEscapeAngle))*distance), sourceLocation.y + (Math.cos(absBearing + (direction*(x/100.0)*maxEscapeAngle))*distance))) { wallDistance = x/100.0; break; } } return wallDistance; }
BattleField { public double orbitalWallDistance(Point2D.Double sourceLocation, Point2D.Double targetLocation, double bulletPower, int direction) { double absBearing = DiaUtils.absoluteBearing(sourceLocation, targetLocation); double distance = sourceLocation.distance(targetLocation); double maxEscapeAngle = Math.asin(8.0/(20-3.0*bulletPower)); double wallDistance = 2.0; for (int x = 0; x < 200; x++) { if (!rectangle.contains( sourceLocation.x + (Math.sin(absBearing + (direction*(x/100.0)*maxEscapeAngle))*distance), sourceLocation.y + (Math.cos(absBearing + (direction*(x/100.0)*maxEscapeAngle))*distance))) { wallDistance = x/100.0; break; } } return wallDistance; } }
BattleField { public double orbitalWallDistance(Point2D.Double sourceLocation, Point2D.Double targetLocation, double bulletPower, int direction) { double absBearing = DiaUtils.absoluteBearing(sourceLocation, targetLocation); double distance = sourceLocation.distance(targetLocation); double maxEscapeAngle = Math.asin(8.0/(20-3.0*bulletPower)); double wallDistance = 2.0; for (int x = 0; x < 200; x++) { if (!rectangle.contains( sourceLocation.x + (Math.sin(absBearing + (direction*(x/100.0)*maxEscapeAngle))*distance), sourceLocation.y + (Math.cos(absBearing + (direction*(x/100.0)*maxEscapeAngle))*distance))) { wallDistance = x/100.0; break; } } return wallDistance; } BattleField(double width, double height); }
BattleField { public double orbitalWallDistance(Point2D.Double sourceLocation, Point2D.Double targetLocation, double bulletPower, int direction) { double absBearing = DiaUtils.absoluteBearing(sourceLocation, targetLocation); double distance = sourceLocation.distance(targetLocation); double maxEscapeAngle = Math.asin(8.0/(20-3.0*bulletPower)); double wallDistance = 2.0; for (int x = 0; x < 200; x++) { if (!rectangle.contains( sourceLocation.x + (Math.sin(absBearing + (direction*(x/100.0)*maxEscapeAngle))*distance), sourceLocation.y + (Math.cos(absBearing + (direction*(x/100.0)*maxEscapeAngle))*distance))) { wallDistance = x/100.0; break; } } return wallDistance; } 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); }
BattleField { public double orbitalWallDistance(Point2D.Double sourceLocation, Point2D.Double targetLocation, double bulletPower, int direction) { double absBearing = DiaUtils.absoluteBearing(sourceLocation, targetLocation); double distance = sourceLocation.distance(targetLocation); double maxEscapeAngle = Math.asin(8.0/(20-3.0*bulletPower)); double wallDistance = 2.0; for (int x = 0; x < 200; x++) { if (!rectangle.contains( sourceLocation.x + (Math.sin(absBearing + (direction*(x/100.0)*maxEscapeAngle))*distance), sourceLocation.y + (Math.cos(absBearing + (direction*(x/100.0)*maxEscapeAngle))*distance))) { wallDistance = x/100.0; break; } } return wallDistance; } 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; }