Merge branch 'wind_(story53)' of https://eng-git.canterbury.ac.nz/seng302-2017/team-7 into wind_(story53)
This commit is contained in:
@@ -23,6 +23,11 @@ public class ShiftingWindGenerator implements WindGenerator {
|
|||||||
private boolean shiftAnticlockwise = false;//true for Back, false for veer
|
private boolean shiftAnticlockwise = false;//true for Back, false for veer
|
||||||
private boolean shiftThisRace = Math.random() > 0.5;
|
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) {
|
public ShiftingWindGenerator(Bearing baselineBearing, double baseLineSpeed) {
|
||||||
this.baselineBearing = baselineBearing;
|
this.baselineBearing = baselineBearing;
|
||||||
this.baseLineSpeed = baseLineSpeed;
|
this.baseLineSpeed = baseLineSpeed;
|
||||||
@@ -39,6 +44,10 @@ public class ShiftingWindGenerator implements WindGenerator {
|
|||||||
return changeWind(currentWind);
|
return changeWind(currentWind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param wind the wind to change
|
||||||
|
* @return the changed wind
|
||||||
|
*/
|
||||||
private Wind changeWind(Wind wind) {
|
private Wind changeWind(Wind wind) {
|
||||||
Wind newWind = new Wind(wind.getWindDirection(), wind.getWindSpeed());
|
Wind newWind = new Wind(wind.getWindDirection(), wind.getWindSpeed());
|
||||||
oscillateWind(newWind);
|
oscillateWind(newWind);
|
||||||
@@ -48,6 +57,10 @@ public class ShiftingWindGenerator implements WindGenerator {
|
|||||||
return newWind;
|
return newWind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* moves the wind 5 degrees up and down
|
||||||
|
* @param wind the wind to oscillate
|
||||||
|
*/
|
||||||
private void oscillateWind(Wind wind) {
|
private void oscillateWind(Wind wind) {
|
||||||
double timeSinceLastOscillationReset = System.currentTimeMillis() - timeOfLastOscillationReset;
|
double timeSinceLastOscillationReset = System.currentTimeMillis() - timeOfLastOscillationReset;
|
||||||
double timeSinceLastChange = System.currentTimeMillis() - timeOfLastChange;
|
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) {
|
private void shiftWind(Wind wind) {
|
||||||
double timeSinceLastShift = System.currentTimeMillis() - timeOfLastShift;
|
double timeSinceLastShift = System.currentTimeMillis() - timeOfLastShift;
|
||||||
double newBearing = wind.getWindDirection().degrees();
|
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) {
|
private void changeWindSpeed(Wind wind) {
|
||||||
double offsetAngle = (wind.getWindDirection().radians() - baselineBearing.radians());
|
double offsetAngle = (wind.getWindDirection().radians() - baselineBearing.radians());
|
||||||
double offset = Math.sin(offsetAngle) * windSpeedVariance;
|
double offset = Math.sin(offsetAngle) * windSpeedVariance;
|
||||||
@@ -109,6 +130,9 @@ public class ShiftingWindGenerator implements WindGenerator {
|
|||||||
wind.setWindSpeed(newWindSpeed);
|
wind.setWindSpeed(newWindSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* starts the wind oscillation direction
|
||||||
|
*/
|
||||||
private void initialiseOscillationDirection() {
|
private void initialiseOscillationDirection() {
|
||||||
anticlockwise = new Random().nextBoolean();
|
anticlockwise = new Random().nextBoolean();
|
||||||
timeOfLastOscillationReset = System.currentTimeMillis();
|
timeOfLastOscillationReset = System.currentTimeMillis();
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 9.2 KiB |
Reference in New Issue
Block a user