From 2ac932b4f3d7fddbbf9091d61a450cffc8891f3b Mon Sep 17 00:00:00 2001 From: hba56 Date: Tue, 23 May 2017 15:17:19 +1200 Subject: [PATCH] fix to keep boats in the bounds #story[#874, 873] --- mock/src/main/java/seng302/Model/Race.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mock/src/main/java/seng302/Model/Race.java b/mock/src/main/java/seng302/Model/Race.java index 98ce3d7c..f0810eaf 100644 --- a/mock/src/main/java/seng302/Model/Race.java +++ b/mock/src/main/java/seng302/Model/Race.java @@ -591,15 +591,14 @@ public class Race implements Runnable { - + Azimuth azimuth = Azimuth.fromBearing(boat.getBearing()); + GPSCoordinate testBounds = GPSCoordinate.calculateNewPosition(boat.getCurrentPosition(), + (100.0 / Constants.NMToMetersConversion), azimuth); //If the new vmg improves velocity, use it. if (improvesVelocity(boat, newVMG)) { boat.setVMG(newVMG); - }else if (!GPSCoordinate.isInsideBoundary(boat.getCurrentPosition(), boundary)){ + }else if (!GPSCoordinate.isInsideBoundary(testBounds, boundary)){ //checks to see if the new vmg sends the boat out of bounds and if so mirrors its direction in the wind - Azimuth azimuth = Azimuth.fromBearing(boat.getBearing()); - GPSCoordinate test = GPSCoordinate.calculateNewPosition(boat.getCurrentPosition(), - (100.0 / Constants.NMToMetersConversion), azimuth); double currDegrees = newVMG.getBearing().degrees(); double windDirectionDegrees = this.windDirection.degrees(); double tempHeading = (currDegrees - windDirectionDegrees +90)%360;