Changed wind speed to be non-linear. #story[1187]

main
Joseph 8 years ago
parent b0f7c5e734
commit 0de7780020

@ -11,7 +11,7 @@ import java.util.Random;
public class ShiftingWindGenerator implements WindGenerator {
Bearing baselineBearing;
double baseLineSpeed;
double speedVariance = 2;
double windSpeedVariance = 5;
double bearingVariance = 5; // In degrees
double oscillationVariance = 0.25;
double oscillationPeriod = 1e3 * 60 * 1; // In milliseconds
@ -61,7 +61,6 @@ public class ShiftingWindGenerator implements WindGenerator {
if (anticlockwise) {
newBearing -= degreeChange;
if (newBearing < baselineBearing.degrees() - bearingVariance) {
System.out.println(timeSinceLastOscillationReset);
anticlockwise = !anticlockwise;
timeOfLastOscillationReset = System.currentTimeMillis();
} else {
@ -70,7 +69,6 @@ public class ShiftingWindGenerator implements WindGenerator {
} else {
newBearing += degreeChange;
if (newBearing > baselineBearing.degrees() + bearingVariance) {
System.out.println(timeSinceLastOscillationReset);
anticlockwise = !anticlockwise;
timeOfLastOscillationReset = System.currentTimeMillis();
} else {
@ -83,10 +81,10 @@ public class ShiftingWindGenerator implements WindGenerator {
}
private void changeWindSpeed(Wind wind) {
double deg = wind.getWindDirection().degrees();
double offset = deg - baselineBearing.degrees();
double newSpeed = offset / bearingVariance * speedVariance + baseLineSpeed;
wind.setWindSpeed(newSpeed);
double offsetAngle = (wind.getWindDirection().radians() - baselineBearing.radians());
double offset = Math.sin(offsetAngle) * windSpeedVariance;
double newWindSpeed = baseLineSpeed + offset;
wind.setWindSpeed(newWindSpeed);
}
private void initialiseOscillationDirection() {
@ -98,8 +96,8 @@ public class ShiftingWindGenerator implements WindGenerator {
this.bearingVariance = maxBearingVariance;
}
public void setSpeedVariance(double speedVariance) {
this.speedVariance = speedVariance;
public void setWindSpeedVariance(double windSpeedVariance) {
this.windSpeedVariance = windSpeedVariance;
}
public void setOscillationPeriod(double oscillationPeriod) {

Loading…
Cancel
Save