diff --git a/racevisionGame/src/main/java/mock/model/wind/ShiftingWindGenerator.java b/racevisionGame/src/main/java/mock/model/wind/ShiftingWindGenerator.java index 1b995a81..5d5e4995 100644 --- a/racevisionGame/src/main/java/mock/model/wind/ShiftingWindGenerator.java +++ b/racevisionGame/src/main/java/mock/model/wind/ShiftingWindGenerator.java @@ -23,6 +23,11 @@ public class ShiftingWindGenerator implements WindGenerator { private boolean shiftAnticlockwise = false;//true for Back, false for veer private boolean shiftThisRace = Math.random() > 0.5; + /** + * Constructor + * @param baselineBearing baseline bearing for wind + * @param baseLineSpeed base line speed for wind + */ public ShiftingWindGenerator(Bearing baselineBearing, double baseLineSpeed) { this.baselineBearing = baselineBearing; this.baseLineSpeed = baseLineSpeed; @@ -39,6 +44,10 @@ public class ShiftingWindGenerator implements WindGenerator { return changeWind(currentWind); } + /** + * @param wind the wind to change + * @return the changed wind + */ private Wind changeWind(Wind wind) { Wind newWind = new Wind(wind.getWindDirection(), wind.getWindSpeed()); oscillateWind(newWind); @@ -48,6 +57,10 @@ public class ShiftingWindGenerator implements WindGenerator { return newWind; } + /** + * moves the wind 5 degrees up and down + * @param wind the wind to oscillate + */ private void oscillateWind(Wind wind) { double timeSinceLastOscillationReset = System.currentTimeMillis() - timeOfLastOscillationReset; double timeSinceLastChange = System.currentTimeMillis() - timeOfLastChange; @@ -78,6 +91,10 @@ public class ShiftingWindGenerator implements WindGenerator { } } + /** + * Slowly shifts the wind up to 180 degrees from where it started + * @param wind the wind to change + */ private void shiftWind(Wind wind) { double timeSinceLastShift = System.currentTimeMillis() - timeOfLastShift; double newBearing = wind.getWindDirection().degrees(); @@ -102,6 +119,10 @@ public class ShiftingWindGenerator implements WindGenerator { } } + /** + * Change the wind speed + * @param wind the wind to change + */ private void changeWindSpeed(Wind wind) { double offsetAngle = (wind.getWindDirection().radians() - baselineBearing.radians()); double offset = Math.sin(offsetAngle) * windSpeedVariance; @@ -109,6 +130,9 @@ public class ShiftingWindGenerator implements WindGenerator { wind.setWindSpeed(newWindSpeed); } + /** + * starts the wind oscillation direction + */ private void initialiseOscillationDirection() { anticlockwise = new Random().nextBoolean(); timeOfLastOscillationReset = System.currentTimeMillis();