Changed wind speed to be non-linear. #story[1187]
This commit is contained in:
@@ -11,7 +11,7 @@ import java.util.Random;
|
|||||||
public class ShiftingWindGenerator implements WindGenerator {
|
public class ShiftingWindGenerator implements WindGenerator {
|
||||||
Bearing baselineBearing;
|
Bearing baselineBearing;
|
||||||
double baseLineSpeed;
|
double baseLineSpeed;
|
||||||
double speedVariance = 2;
|
double windSpeedVariance = 5;
|
||||||
double bearingVariance = 5; // In degrees
|
double bearingVariance = 5; // In degrees
|
||||||
double oscillationVariance = 0.25;
|
double oscillationVariance = 0.25;
|
||||||
double oscillationPeriod = 1e3 * 60 * 1; // In milliseconds
|
double oscillationPeriod = 1e3 * 60 * 1; // In milliseconds
|
||||||
@@ -61,7 +61,6 @@ public class ShiftingWindGenerator implements WindGenerator {
|
|||||||
if (anticlockwise) {
|
if (anticlockwise) {
|
||||||
newBearing -= degreeChange;
|
newBearing -= degreeChange;
|
||||||
if (newBearing < baselineBearing.degrees() - bearingVariance) {
|
if (newBearing < baselineBearing.degrees() - bearingVariance) {
|
||||||
System.out.println(timeSinceLastOscillationReset);
|
|
||||||
anticlockwise = !anticlockwise;
|
anticlockwise = !anticlockwise;
|
||||||
timeOfLastOscillationReset = System.currentTimeMillis();
|
timeOfLastOscillationReset = System.currentTimeMillis();
|
||||||
} else {
|
} else {
|
||||||
@@ -70,7 +69,6 @@ public class ShiftingWindGenerator implements WindGenerator {
|
|||||||
} else {
|
} else {
|
||||||
newBearing += degreeChange;
|
newBearing += degreeChange;
|
||||||
if (newBearing > baselineBearing.degrees() + bearingVariance) {
|
if (newBearing > baselineBearing.degrees() + bearingVariance) {
|
||||||
System.out.println(timeSinceLastOscillationReset);
|
|
||||||
anticlockwise = !anticlockwise;
|
anticlockwise = !anticlockwise;
|
||||||
timeOfLastOscillationReset = System.currentTimeMillis();
|
timeOfLastOscillationReset = System.currentTimeMillis();
|
||||||
} else {
|
} else {
|
||||||
@@ -83,10 +81,10 @@ public class ShiftingWindGenerator implements WindGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void changeWindSpeed(Wind wind) {
|
private void changeWindSpeed(Wind wind) {
|
||||||
double deg = wind.getWindDirection().degrees();
|
double offsetAngle = (wind.getWindDirection().radians() - baselineBearing.radians());
|
||||||
double offset = deg - baselineBearing.degrees();
|
double offset = Math.sin(offsetAngle) * windSpeedVariance;
|
||||||
double newSpeed = offset / bearingVariance * speedVariance + baseLineSpeed;
|
double newWindSpeed = baseLineSpeed + offset;
|
||||||
wind.setWindSpeed(newSpeed);
|
wind.setWindSpeed(newWindSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialiseOscillationDirection() {
|
private void initialiseOscillationDirection() {
|
||||||
@@ -98,8 +96,8 @@ public class ShiftingWindGenerator implements WindGenerator {
|
|||||||
this.bearingVariance = maxBearingVariance;
|
this.bearingVariance = maxBearingVariance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpeedVariance(double speedVariance) {
|
public void setWindSpeedVariance(double windSpeedVariance) {
|
||||||
this.speedVariance = speedVariance;
|
this.windSpeedVariance = windSpeedVariance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOscillationPeriod(double oscillationPeriod) {
|
public void setOscillationPeriod(double oscillationPeriod) {
|
||||||
|
|||||||
Reference in New Issue
Block a user