|
|
|
@ -3,18 +3,28 @@ package mock.model.wind;
|
|
|
|
import shared.model.Bearing;
|
|
|
|
import shared.model.Bearing;
|
|
|
|
import shared.model.Wind;
|
|
|
|
import shared.model.Wind;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Created by jjg64 on 28/08/17.
|
|
|
|
* Created by jjg64 on 28/08/17.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class ShiftingWindGenerator implements WindGenerator {
|
|
|
|
public class ShiftingWindGenerator implements WindGenerator {
|
|
|
|
Bearing baselineBearing;
|
|
|
|
Bearing baselineBearing;
|
|
|
|
double baseLineSpeed;
|
|
|
|
double baseLineSpeed;
|
|
|
|
double maxBearingVariance = 5; // In degrees
|
|
|
|
double speedVariance = 4;
|
|
|
|
|
|
|
|
double bearingVariance = 5; // In degrees
|
|
|
|
double oscillationPeriod = 3e6; // In milliseconds
|
|
|
|
double oscillationPeriod = 3e6; // In milliseconds
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double timeOfLastOscillationReset = 0;
|
|
|
|
|
|
|
|
double timeSinceLastChange = 0;
|
|
|
|
|
|
|
|
double timeSinceLastShift = 0; // Back / veer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean oscillationLeft = false;
|
|
|
|
|
|
|
|
|
|
|
|
public ShiftingWindGenerator(Bearing baselineBearing, double baseLineSpeed) {
|
|
|
|
public ShiftingWindGenerator(Bearing baselineBearing, double baseLineSpeed) {
|
|
|
|
this.baselineBearing = baselineBearing;
|
|
|
|
this.baselineBearing = baselineBearing;
|
|
|
|
this.baseLineSpeed = baseLineSpeed;
|
|
|
|
this.baseLineSpeed = baseLineSpeed;
|
|
|
|
|
|
|
|
initialiseOscillationDirection();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@ -27,22 +37,39 @@ public class ShiftingWindGenerator implements WindGenerator {
|
|
|
|
return changeWind(currentWind);
|
|
|
|
return changeWind(currentWind);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Wind changeWind(Wind currentWind) {
|
|
|
|
private Wind changeWind(Wind wind) {
|
|
|
|
currentWind = oscillateWind(currentWind);
|
|
|
|
Wind newWind = new Wind(wind.getWindDirection(), wind.getWindSpeed());
|
|
|
|
currentWind = shiftWind(currentWind);
|
|
|
|
oscillateWind(newWind);
|
|
|
|
return currentWind;
|
|
|
|
shiftWind(newWind);
|
|
|
|
|
|
|
|
changeWindSpeed(newWind);
|
|
|
|
|
|
|
|
return newWind;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void oscillateWind(Wind wind) {
|
|
|
|
|
|
|
|
double timeSinceLastOscillationReset = System.currentTimeMillis() - timeOfLastOscillationReset;
|
|
|
|
|
|
|
|
if (oscillationLeft) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void shiftWind(Wind wind) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void changeWindSpeed(Wind wind) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Wind oscillateWind(Wind currentWind) {
|
|
|
|
private void initialiseOscillationDirection() {
|
|
|
|
return currentWind;
|
|
|
|
oscillationLeft = new Random().nextBoolean();
|
|
|
|
|
|
|
|
timeOfLastOscillationReset = System.currentTimeMillis();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Wind shiftWind(Wind currentWind) {
|
|
|
|
public void setBearingVariance(double maxBearingVariance) {
|
|
|
|
return currentWind;
|
|
|
|
this.bearingVariance = maxBearingVariance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setMaxBearingVariance(double maxBearingVariance) {
|
|
|
|
public void setSpeedVariance(double speedVariance) {
|
|
|
|
this.maxBearingVariance = maxBearingVariance;
|
|
|
|
this.speedVariance = speedVariance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setOscillationPeriod(double oscillationPeriod) {
|
|
|
|
public void setOscillationPeriod(double oscillationPeriod) {
|
|
|
|
|