diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..58ae3a1
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+ThrustScaler
\ No newline at end of file
diff --git a/.idea/ant.xml b/.idea/ant.xml
new file mode 100644
index 0000000..a2a4769
--- /dev/null
+++ b/.idea/ant.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/MultiLevelWind.xml b/.idea/libraries/MultiLevelWind.xml
new file mode 100644
index 0000000..9bb7c0d
--- /dev/null
+++ b/.idea/libraries/MultiLevelWind.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..31602d7
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..74e3e93
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MultiLevelWind.iml b/MultiLevelWind.iml
new file mode 100644
index 0000000..9c69e79
--- /dev/null
+++ b/MultiLevelWind.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/MultiLevelWind.jar b/MultiLevelWind.jar
index db5dda5..eb2d7b9 100644
Binary files a/MultiLevelWind.jar and b/MultiLevelWind.jar differ
diff --git a/OpenRocket.jar b/OpenRocket.jar
index 4bfbe3c..6c69ca1 100644
Binary files a/OpenRocket.jar and b/OpenRocket.jar differ
diff --git a/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWind.class b/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWind.class
new file mode 100644
index 0000000..1247c58
Binary files /dev/null and b/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWind.class differ
diff --git a/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindConfigurator.class b/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindConfigurator.class
new file mode 100644
index 0000000..0de6a5e
Binary files /dev/null and b/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindConfigurator.class differ
diff --git a/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindModel$WindModelAndAltitude.class b/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindModel$WindModelAndAltitude.class
new file mode 100644
index 0000000..3fef0f1
Binary files /dev/null and b/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindModel$WindModelAndAltitude.class differ
diff --git a/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindModel$WindSpecs.class b/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindModel$WindSpecs.class
new file mode 100644
index 0000000..579e148
Binary files /dev/null and b/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindModel$WindSpecs.class differ
diff --git a/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindModel.class b/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindModel.class
new file mode 100644
index 0000000..d47fff7
Binary files /dev/null and b/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindModel.class differ
diff --git a/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindProvider.class b/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindProvider.class
new file mode 100644
index 0000000..27b7a99
Binary files /dev/null and b/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindProvider.class differ
diff --git a/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindSimulationListener.class b/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindSimulationListener.class
new file mode 100644
index 0000000..57ec610
Binary files /dev/null and b/classes/production/MultiLevelWind/net/sf/openrocket/example/MultiLevelWindSimulationListener.class differ
diff --git a/src/net/sf/openrocket/example/MultiLevelWind.java b/src/net/sf/openrocket/example/MultiLevelWind.java
index 201c3b8..4de349c 100644
--- a/src/net/sf/openrocket/example/MultiLevelWind.java
+++ b/src/net/sf/openrocket/example/MultiLevelWind.java
@@ -36,13 +36,13 @@ public String getName() {
}
}
for (int i = 0; i <= lastUsedLevel && i < 5; i++) {
- label = label + System.lineSeparator() + getWindLabel(i);
+ label = label + System.lineSeparator() + " " + getWindLabel(i);
}
return label + "...";
}
private String getWindLabel(int idx) {
- return String.format("%d%d\u00B0%dᵐᵖʰ",
+ return String.format("%d%d\u00B0%d\u1d50\u1d56\u02b0",
Math.round(getWindAlt(idx) / 0.3048),
Math.round(360.0 * getWindDirection(idx) / (Math.PI * 2)),
Math.round(getWind(idx) / 0.44704));
diff --git a/src/net/sf/openrocket/example/MultiLevelWindModel.java b/src/net/sf/openrocket/example/MultiLevelWindModel.java
new file mode 100644
index 0000000..59b1d29
--- /dev/null
+++ b/src/net/sf/openrocket/example/MultiLevelWindModel.java
@@ -0,0 +1,115 @@
+package net.sf.openrocket.example;
+
+import org.slf4j.LoggerFactory;
+import net.sf.openrocket.util.Coordinate;
+import java.util.ArrayList;
+import java.util.List;
+import net.sf.openrocket.models.wind.PinkNoiseWindModel;
+import org.slf4j.Logger;
+import net.sf.openrocket.models.wind.WindModel;
+
+public class MultiLevelWindModel implements WindModel
+{
+ private static final Logger log;
+ private PinkNoiseWindModel mainWindModel;
+ private List windSpecs;
+
+ public MultiLevelWindModel(final List winds) {
+ this.mainWindModel = new PinkNoiseWindModel(10);
+ this.windSpecs = null;
+ this.windSpecs = new ArrayList();
+ for (final WindSpecs windSpec : winds) {
+ this.windSpecs.add(new WindSpecs(windSpec.altitude, windSpec.speed, windSpec.direction));
+ }
+ this.mainWindModel.setAverage(this.windSpecs.get(0).speed);
+ this.mainWindModel.setDirection(this.windSpecs.get(0).direction);
+ }
+
+ public int getModID() {
+ return 0;
+ }
+
+ public void setStandardDeviation(final double standardDeviation) {
+ this.mainWindModel.setStandardDeviation(standardDeviation);
+ }
+
+ public void setTurbulenceIntensity(final double intensity) {
+ this.mainWindModel.setTurbulenceIntensity(intensity);
+ }
+
+ public Coordinate getWindVelocity(final double time, final double altitude) {
+ WindSpecs last_m = null;
+ for (final WindSpecs m : this.windSpecs) {
+ if (m.altitude >= altitude) {
+ return this.interpolateWindVelocity(time, altitude, last_m, m);
+ }
+ last_m = m;
+ }
+ final Coordinate ret = this.interpolateWindVelocity(time, altitude, last_m, null);
+ return ret;
+ }
+
+ private double interpolate(final double v1, final double v2, final double w) {
+ return v1 + (v2 - v1) * w;
+ }
+
+ private String modelToString(final WindSpecs m) {
+ if (m == null) {
+ return "(null)";
+ }
+ return String.format("%dft %ddegrees %dspeed", Math.round(m.altitude), Math.round(m.direction * 180.0 / 3.141592653589793), Math.round(m.speed));
+ }
+
+ private Coordinate interpolateWindVelocity(final double time, final double altitude, final WindSpecs m1, final WindSpecs m2) {
+ double speed = 0.0;
+ double direction = 0.0;
+ if (m1 == null) {
+ speed = m2.speed;
+ direction = m2.direction;
+ }
+ else if (m2 == null) {
+ speed = m1.speed;
+ direction = m1.direction;
+ }
+ else {
+ final double a = (altitude - m1.altitude) / (m2.altitude - m1.altitude);
+ speed = this.interpolate(m1.speed, m2.speed, a);
+ final double sinSum = (1.0 - a) * Math.sin(m1.direction) + a * Math.sin(m2.direction);
+ final double cosSum = (1.0 - a) * Math.cos(m1.direction) + a * Math.cos(m2.direction);
+ direction = Math.atan2(sinSum, cosSum);
+ }
+ this.mainWindModel.setAverage(speed);
+ this.mainWindModel.setDirection(direction);
+ final Coordinate ret = this.mainWindModel.getWindVelocity(time, altitude);
+ MultiLevelWindModel.log.debug(String.format("interpolating alt %f between layers %s and %s returning %s", altitude, this.modelToString(m1), this.modelToString(m2), ret.toString()));
+ return ret;
+ }
+
+ static {
+ log = LoggerFactory.getLogger((Class)MultiLevelWindModel.class);
+ }
+
+ public static class WindSpecs
+ {
+ public final double altitude;
+ public final double speed;
+ public final double direction;
+
+ public WindSpecs(final double a, final double s, final double d) {
+ this.altitude = a;
+ this.speed = s;
+ this.direction = d;
+ }
+ }
+
+ private class WindModelAndAltitude
+ {
+ public final PinkNoiseWindModel windModel;
+ public final double altitude;
+
+ public WindModelAndAltitude(final PinkNoiseWindModel w, final double a) {
+ this.windModel = w;
+ this.altitude = a;
+ }
+ }
+}
\ No newline at end of file