From 6ce7f0c23a78a05bc169d8cc6e0ee4d7f2c78f27 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Sat, 20 Dec 2014 20:55:15 -0700 Subject: [PATCH 1/3] Added configurable wind direction in simulation options. - added Ground Track plot type - changed parameter names to East-West/North-South from parallel to wind and lateral --- core/resources/l10n/messages.properties | 7 +++-- .../models/wind/PinkNoiseWindModel.java | 29 ++++++++++++------- .../simulation/SimulationOptions.java | 27 ++++++++++++++++- .../gui/plot/PlotConfiguration.java | 12 ++++++++ .../simulation/SimulationConditionsPanel.java | 26 ++++++++++++++++- 5 files changed, 86 insertions(+), 15 deletions(-) diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 11ccd3456..7bf394c88 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -332,6 +332,8 @@ simedtdlg.lbl.Wind = Wind simedtdlg.lbl.Averwindspeed = Average windspeed: simedtdlg.lbl.ttip.Averwindspeed = The average windspeed relative to the ground. simedtdlg.lbl.Stddeviation = Standard deviation: +simedtdlg.lbl.Winddirection = Wind direction: +simedtdlg.lbl.ttip.Winddirection = Wind direction, 0-360 degrees.
0 means from the north,
90 is from the east simedtdlg.lbl.ttip.Stddeviation = The standard deviation of the windspeed.
The windspeed is within twice the standard deviation from the average for 95% of the time. simedtdlg.lbl.Turbulenceintensity = Turbulence intensity: simedtdlg.lbl.ttip.Turbulenceintensity1 = The turbulence intensity is the standard deviation divided by the average windspeed.
@@ -1477,8 +1479,8 @@ FlightDataType.TYPE_VELOCITY_Z = Vertical velocity FlightDataType.TYPE_ACCELERATION_Z = Vertical acceleration FlightDataType.TYPE_VELOCITY_TOTAL = Total velocity FlightDataType.TYPE_ACCELERATION_TOTAL = Total acceleration -FlightDataType.TYPE_POSITION_X = Position upwind -FlightDataType.TYPE_POSITION_Y = Position parallel to wind +FlightDataType.TYPE_POSITION_X = Position East-West +FlightDataType.TYPE_POSITION_Y = Position North-South FlightDataType.TYPE_POSITION_XY = Lateral distance FlightDataType.TYPE_POSITION_DIRECTION = Lateral direction FlightDataType.TYPE_VELOCITY_XY = Lateral velocity @@ -1536,6 +1538,7 @@ PlotConfiguration.Dragcoef = Drag coefficients vs. Mach number PlotConfiguration.Rollcharacteristics = Roll characteristics PlotConfiguration.Angleofattack = Angle of attack and orientation vs. time PlotConfiguration.Simulationtime = Simulation time step and computation time +PlotConfiguration.Groundtrack = Ground track ! Warning Warning.LargeAOA.str1 = Large angle of attack encountered. diff --git a/core/src/net/sf/openrocket/models/wind/PinkNoiseWindModel.java b/core/src/net/sf/openrocket/models/wind/PinkNoiseWindModel.java index 960325d5f..e9ee2a7a3 100644 --- a/core/src/net/sf/openrocket/models/wind/PinkNoiseWindModel.java +++ b/core/src/net/sf/openrocket/models/wind/PinkNoiseWindModel.java @@ -18,8 +18,8 @@ public class PinkNoiseWindModel implements WindModel { /** Random value with which to XOR the random seed value */ private static final int SEED_RANDOMIZATION = 0x7343AA03; - - + + /** Pink noise alpha parameter. */ private static final double ALPHA = 5.0 / 3.0; @@ -32,8 +32,9 @@ public class PinkNoiseWindModel implements WindModel { /** Time difference between random samples. */ private static final double DELTA_T = 0.05; - + private double average = 0; + private double direction = Math.PI / 2; // this is an East wind private double standardDeviation = 0; private final int seed; @@ -52,7 +53,7 @@ public class PinkNoiseWindModel implements WindModel { } - + /** * Return the average wind speed. * @@ -74,8 +75,14 @@ public class PinkNoiseWindModel implements WindModel { setTurbulenceIntensity(intensity); } + public void setDirection(double direction) { + this.direction = direction; + } + + public double getDirection() { + return this.direction; + } - /** * Return the standard deviation from the average wind speed. * @@ -120,9 +127,9 @@ public class PinkNoiseWindModel implements WindModel { } - - - + + + @Override public Coordinate getWindVelocity(double time, double altitude) { if (time < 0) { @@ -150,8 +157,8 @@ public class PinkNoiseWindModel implements WindModel { double a = (time - time1) / DELTA_T; double speed = average + (value1 * (1 - a) + value2 * a) * standardDeviation / STDDEV; - // TODO: MEDIUM: Make wind direction configurable - return new Coordinate(speed, 0, 0); + return new Coordinate(speed * Math.sin(direction), speed * Math.cos(direction), 0); + } @@ -160,7 +167,7 @@ public class PinkNoiseWindModel implements WindModel { } - + @Override public int getModID() { return (int) (average * 1000 + standardDeviation); diff --git a/core/src/net/sf/openrocket/simulation/SimulationOptions.java b/core/src/net/sf/openrocket/simulation/SimulationOptions.java index f32c01407..bb8bfaf82 100644 --- a/core/src/net/sf/openrocket/simulation/SimulationOptions.java +++ b/core/src/net/sf/openrocket/simulation/SimulationOptions.java @@ -68,7 +68,7 @@ public class SimulationOptions implements ChangeSource, Cloneable { private double windAverage = 2.0; private double windTurbulence = 0.1; - + private double windDirection = Math.PI / 2; /* * SimulationOptions maintains the launch site parameters as separate double values, @@ -211,8 +211,25 @@ public class SimulationOptions implements ChangeSource, Cloneable { } + /** + * Set the wind direction + * + * @param direction the wind direction + */ + public void setWindDirection(double direction) { + direction = MathUtil.reduce360(direction); + if (MathUtil.equals(this.windDirection, direction)) + return; + this.windDirection = direction; + fireChangeEvent(); + + } + public double getWindDirection() { + return this.windDirection; + + } public double getLaunchAltitude() { return launchAltitude; @@ -446,6 +463,7 @@ public class SimulationOptions implements ChangeSource, Cloneable { this.timeStep = src.timeStep; this.windAverage = src.windAverage; this.windTurbulence = src.windTurbulence; + this.windDirection = src.windDirection; this.calculateExtras = src.calculateExtras; this.randomSeed = src.randomSeed; @@ -501,6 +519,10 @@ public class SimulationOptions implements ChangeSource, Cloneable { isChanged = true; this.windAverage = src.windAverage; } + if (this.windDirection != src.windDirection) { + isChanged = true; + this.windDirection = src.windDirection; + } if (this.windTurbulence != src.windTurbulence) { isChanged = true; this.windTurbulence = src.windTurbulence; @@ -542,6 +564,7 @@ public class SimulationOptions implements ChangeSource, Cloneable { MathUtil.equals(this.timeStep, o.timeStep) && MathUtil.equals(this.windAverage, o.windAverage) && MathUtil.equals(this.windTurbulence, o.windTurbulence) && + MathUtil.equals(this.windDirection, o.windDirection) && this.calculateExtras == o.calculateExtras && this.randomSeed == o.randomSeed); } @@ -595,6 +618,8 @@ public class SimulationOptions implements ChangeSource, Cloneable { PinkNoiseWindModel windModel = new PinkNoiseWindModel(randomSeed); windModel.setAverage(getWindSpeedAverage()); windModel.setStandardDeviation(getWindSpeedDeviation()); + windModel.setDirection(windDirection); + conditions.setWindModel(windModel); conditions.setAtmosphericModel(getAtmosphericModel()); diff --git a/swing/src/net/sf/openrocket/gui/plot/PlotConfiguration.java b/swing/src/net/sf/openrocket/gui/plot/PlotConfiguration.java index 8f1f455de..e700c9080 100644 --- a/swing/src/net/sf/openrocket/gui/plot/PlotConfiguration.java +++ b/swing/src/net/sf/openrocket/gui/plot/PlotConfiguration.java @@ -67,6 +67,18 @@ public class PlotConfiguration implements Cloneable { config.setEvent(FlightEvent.Type.TUMBLE, true); config.setEvent(FlightEvent.Type.EXCEPTION, true); configs.add(config); + + + //// Ground track + config = new PlotConfiguration(trans.get("PlotConfiguration.Groundtrack"), FlightDataType.TYPE_POSITION_X); + config.addPlotDataType(FlightDataType.TYPE_POSITION_Y, 0); + config.addPlotDataType(FlightDataType.TYPE_ALTITUDE, 1); + config.setEvent(FlightEvent.Type.IGNITION, true); + config.setEvent(FlightEvent.Type.BURNOUT, true); + config.setEvent(FlightEvent.Type.APOGEE, true); + config.setEvent(FlightEvent.Type.RECOVERY_DEVICE_DEPLOYMENT, true); + config.setEvent(FlightEvent.Type.GROUND_HIT, true); + configs.add(config); //// Stability vs. time config = new PlotConfiguration(trans.get("PlotConfiguration.Stability")); diff --git a/swing/src/net/sf/openrocket/gui/simulation/SimulationConditionsPanel.java b/swing/src/net/sf/openrocket/gui/simulation/SimulationConditionsPanel.java index 2839704b1..f21746f4a 100644 --- a/swing/src/net/sf/openrocket/gui/simulation/SimulationConditionsPanel.java +++ b/swing/src/net/sf/openrocket/gui/simulation/SimulationConditionsPanel.java @@ -43,7 +43,7 @@ public class SimulationConditionsPanel extends JPanel { DoubleModel m; JSpinner spin; - //// Wind settings: Average wind speed, turbulence intensity, std. deviation + //// Wind settings: Average wind speed, turbulence intensity, std. deviation, and direction sub = new JPanel(new MigLayout("fill, gap rel unrel", "[grow][65lp!][30lp!][75lp!]", "")); //// Wind @@ -100,6 +100,30 @@ public class SimulationConditionsPanel extends JPanel { slider.setToolTipText(tip); sub.add(slider, "w 75lp, wrap"); + // Wind Direction: + label = new JLabel(trans.get("simedtdlg.lbl.Winddirection")); + //// Direction of the wind. 0 is north + tip = trans.get("simedtdlg.lbl.ttip.Winddirection"); + label.setToolTipText(tip); + sub.add(label); + + m = new DoubleModel(conditions, "WindDirection", 1.0, UnitGroup.UNITS_ANGLE, + 0, 2*Math.PI); + + spin = new JSpinner(m.getSpinnerModel()); + spin.setEditor(new SpinnerEditor(spin)); + spin.setToolTipText(tip); + sub.add(spin, "w 65lp!"); + + unit = new UnitSelector(m); + unit.setToolTipText(tip); + sub.add(unit, "growx"); + slider = new BasicSlider(m.getSliderModel(0, 2*Math.PI)); + slider.setToolTipText(tip); + sub.add(slider, "w 75lp, wrap"); + + + // Wind turbulence intensity //// Turbulence intensity: From b96277afa0f510c5223a4b847f2ec0224c875f6c Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Sun, 21 Dec 2014 20:05:57 -0700 Subject: [PATCH 2/3] Launch rod is now 0 North and decoupled from wind direction. --- core/resources/l10n/messages.properties | 15 ++++++---- .../file/openrocket/OpenRocketSaver.java | 2 +- .../importt/SimulationConditionsHandler.java | 4 +-- .../simulation/RK4SimulationStepper.java | 12 ++++---- .../simulation/SimulationConditions.java | 2 +- .../simulation/SimulationOptions.java | 18 +++++++++--- .../simulation/SimulationStatus.java | 4 +-- .../simulation/SimulationConditionsPanel.java | 29 +++++++++++++------ 8 files changed, 56 insertions(+), 30 deletions(-) diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 6bb9d119f..d124867cf 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -366,12 +366,17 @@ simedtdlg.lbl.ttip.Altitude = The launch altitude above mean sea level.
Checking this box makes the launch rod point into the wind.
+simedtdlg.checkbox.ttip.Intowind2 = A zero launchrod angle will point directly up.
+simedtdlg.checkbox.ttip.Intowind3 = A negative launchrod angle will launch with the wind.
If you uncheck this box you can point the launchrod any direction you please. +simedtdlg.checkbox.ttip.Intowind4 = If you uncheck this box you can point the launchrod any direction you please. simedtdlg.lbl.Angle = Angle: -simedtdlg.lbl.ttip.Angle = The angle of the launch rod from vertical. +simedtdlg.lbl.ttip.Angle = The angle of the launch rod from vertical.
Positive angles point upwind. simedtdlg.lbl.Direction = Direction: simedtdlg.lbl.ttip.Direction1 = Direction of the launch rod relative to the wind.
-simedtdlg.lbl.ttip.Direction2 = = towards the wind, -simedtdlg.lbl.ttip.Direction3 = = downwind. +simedtdlg.lbl.ttip.Direction2 = - +simedtdlg.lbl.ttip.Direction3 = 0 is North. simedtdlg.border.Simopt = Simulator options simedtdlg.lbl.Calcmethod = Calculation method: simedtdlg.lbl.ttip.Calcmethod = The Extended Barrowman method calculates aerodynamic forces according
to the Barrowman equations extended to accommodate more components. @@ -1485,8 +1490,8 @@ FlightDataType.TYPE_VELOCITY_Z = Vertical velocity FlightDataType.TYPE_ACCELERATION_Z = Vertical acceleration FlightDataType.TYPE_VELOCITY_TOTAL = Total velocity FlightDataType.TYPE_ACCELERATION_TOTAL = Total acceleration -FlightDataType.TYPE_POSITION_X = Position East-West -FlightDataType.TYPE_POSITION_Y = Position North-South +FlightDataType.TYPE_POSITION_X = Position East of launch +FlightDataType.TYPE_POSITION_Y = Position North of launch FlightDataType.TYPE_POSITION_XY = Lateral distance FlightDataType.TYPE_POSITION_DIRECTION = Lateral direction FlightDataType.TYPE_VELOCITY_XY = Lateral velocity diff --git a/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java b/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java index a21354f7f..cea1e2a9d 100644 --- a/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/OpenRocketSaver.java @@ -431,7 +431,7 @@ public class OpenRocketSaver extends RocketSaver { writeElement("configid", cond.getMotorConfigurationID()); writeElement("launchrodlength", cond.getLaunchRodLength()); writeElement("launchrodangle", cond.getLaunchRodAngle() * 180.0 / Math.PI); - writeElement("launchroddirection", cond.getLaunchRodDirection() * 180.0 / Math.PI); + writeElement("launchroddirection", cond.getLaunchRodDirection() * 360.0 / (2.0 * Math.PI)); writeElement("windaverage", cond.getWindSpeedAverage()); writeElement("windturbulence", cond.getWindTurbulenceIntensity()); writeElement("launchaltitude", cond.getLaunchAltitude()); diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/SimulationConditionsHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/SimulationConditionsHandler.java index f0cde3a4c..2094b0320 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/SimulationConditionsHandler.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/SimulationConditionsHandler.java @@ -70,7 +70,7 @@ class SimulationConditionsHandler extends AbstractElementHandler { if (Double.isNaN(d)) { warnings.add("Illegal launch rod direction defined, ignoring."); } else { - conditions.setLaunchRodDirection(d * Math.PI / 180); + conditions.setLaunchRodDirection(d * 2.0 * Math.PI / 360); } } else if (element.equals("windaverage")) { if (Double.isNaN(d)) { @@ -113,7 +113,7 @@ class SimulationConditionsHandler extends AbstractElementHandler { } else if (element.equals("atmosphere")) { atmosphereHandler.storeSettings(conditions, warnings); } else if (element.equals("timestep")) { - if (Double.isNaN(d) || d <= 0 ) { + if (Double.isNaN(d) || d <= 0) { warnings.add("Illegal time step defined, ignoring."); } else { conditions.setTimeStep(d); diff --git a/core/src/net/sf/openrocket/simulation/RK4SimulationStepper.java b/core/src/net/sf/openrocket/simulation/RK4SimulationStepper.java index 9ddfec972..d431569af 100644 --- a/core/src/net/sf/openrocket/simulation/RK4SimulationStepper.java +++ b/core/src/net/sf/openrocket/simulation/RK4SimulationStepper.java @@ -59,24 +59,24 @@ public class RK4SimulationStepper extends AbstractSimulationStepper { private static final double MIN_TIME_STEP = 0.001; - + private Random random; - - + + @Override public RK4SimulationStatus initialize(SimulationStatus original) { RK4SimulationStatus status = new RK4SimulationStatus(original); // Copy the existing warnings - status.setWarnings( original.getWarnings() ); + status.setWarnings(original.getWarnings()); SimulationConditions sim = original.getSimulationConditions(); status.setLaunchRodDirection(new Coordinate( - Math.sin(sim.getLaunchRodAngle()) * Math.cos(sim.getLaunchRodDirection()), - Math.sin(sim.getLaunchRodAngle()) * Math.sin(sim.getLaunchRodDirection()), + Math.sin(sim.getLaunchRodAngle()) * Math.cos(Math.PI / 2.0 - sim.getLaunchRodDirection()), + Math.sin(sim.getLaunchRodAngle()) * Math.sin(Math.PI / 2.0 - sim.getLaunchRodDirection()), Math.cos(sim.getLaunchRodAngle()) )); diff --git a/core/src/net/sf/openrocket/simulation/SimulationConditions.java b/core/src/net/sf/openrocket/simulation/SimulationConditions.java index 61bad44c6..067417d3b 100644 --- a/core/src/net/sf/openrocket/simulation/SimulationConditions.java +++ b/core/src/net/sf/openrocket/simulation/SimulationConditions.java @@ -35,7 +35,7 @@ public class SimulationConditions implements Monitorable, Cloneable { /** Launch rod angle >= 0, radians from vertical */ private double launchRodAngle = 0; - /** Launch rod direction, 0 = upwind, PI = downwind. */ + /** Launch rod direction, 0 = north */ private double launchRodDirection = 0; // TODO: Depreciate these and use worldCoordinate only. diff --git a/core/src/net/sf/openrocket/simulation/SimulationOptions.java b/core/src/net/sf/openrocket/simulation/SimulationOptions.java index bb8bfaf82..ba8110cd7 100644 --- a/core/src/net/sf/openrocket/simulation/SimulationOptions.java +++ b/core/src/net/sf/openrocket/simulation/SimulationOptions.java @@ -59,10 +59,12 @@ public class SimulationOptions implements ChangeSource, Cloneable { private double launchRodLength = 1; - /** Launch rod angle > 0, radians from vertical */ + /** Keep launch rod parallel to wind*/ + private boolean launchIntoWind = true; + /** Launch rod angle, |radians|<90 from vertical, positive is upwind, negative is downwind */ private double launchRodAngle = 0; - /** Launch rod direction, 0 = upwind, PI = downwind. */ + /** Launch rod direction, 0 = north. */ private double launchRodDirection = 0; @@ -139,12 +141,20 @@ public class SimulationOptions implements ChangeSource, Cloneable { } + public boolean getLaunchIntoWind() { + return launchIntoWind; + } + + public void setLaunchIntoWind(boolean i) { + launchIntoWind = i; + } + public double getLaunchRodAngle() { return launchRodAngle; } public void setLaunchRodAngle(double launchRodAngle) { - launchRodAngle = MathUtil.clamp(launchRodAngle, 0, MAX_LAUNCH_ROD_ANGLE); + launchRodAngle = MathUtil.clamp(launchRodAngle, -MAX_LAUNCH_ROD_ANGLE, MAX_LAUNCH_ROD_ANGLE); if (MathUtil.equals(this.launchRodAngle, launchRodAngle)) return; this.launchRodAngle = launchRodAngle; @@ -157,7 +167,7 @@ public class SimulationOptions implements ChangeSource, Cloneable { } public void setLaunchRodDirection(double launchRodDirection) { - launchRodDirection = MathUtil.reduce180(launchRodDirection); + launchRodDirection = MathUtil.reduce360(launchRodDirection); if (MathUtil.equals(this.launchRodDirection, launchRodDirection)) return; this.launchRodDirection = launchRodDirection; diff --git a/core/src/net/sf/openrocket/simulation/SimulationStatus.java b/core/src/net/sf/openrocket/simulation/SimulationStatus.java index 79b266a5a..17998a551 100644 --- a/core/src/net/sf/openrocket/simulation/SimulationStatus.java +++ b/core/src/net/sf/openrocket/simulation/SimulationStatus.java @@ -103,12 +103,12 @@ public class SimulationStatus implements Monitorable { Quaternion o; FlightConditions cond = new FlightConditions(this.configuration); this.simulationConditions.getAerodynamicCalculator().getWorstCP(this.configuration, cond, null); - double angle = -cond.getTheta() - this.simulationConditions.getLaunchRodDirection(); + double angle = -cond.getTheta() - (Math.PI / 2.0 - this.simulationConditions.getLaunchRodDirection()); o = Quaternion.rotation(new Coordinate(0, 0, angle)); // Launch rod angle and direction o = o.multiplyLeft(Quaternion.rotation(new Coordinate(0, this.simulationConditions.getLaunchRodAngle(), 0))); - o = o.multiplyLeft(Quaternion.rotation(new Coordinate(0, 0, this.simulationConditions.getLaunchRodDirection()))); + o = o.multiplyLeft(Quaternion.rotation(new Coordinate(0, 0, Math.PI / 2.0 - this.simulationConditions.getLaunchRodDirection()))); this.orientation = o; this.rotationVelocity = Coordinate.NUL; diff --git a/swing/src/net/sf/openrocket/gui/simulation/SimulationConditionsPanel.java b/swing/src/net/sf/openrocket/gui/simulation/SimulationConditionsPanel.java index f21746f4a..0ba49a3fc 100644 --- a/swing/src/net/sf/openrocket/gui/simulation/SimulationConditionsPanel.java +++ b/swing/src/net/sf/openrocket/gui/simulation/SimulationConditionsPanel.java @@ -352,7 +352,19 @@ public class SimulationConditionsPanel extends JPanel { slider.setToolTipText(tip); sub.add(slider, "w 75lp, wrap"); + // Keep launch rod parallel to the wind. + BooleanModel intoWind = new BooleanModel(conditions, "LaunchIntoWind"); + JCheckBox checkWind = new JCheckBox(intoWind); + //// Use International Standard Atmosphere + checkWind.setText(trans.get("simedtdlg.checkbox.Intowind")); + checkWind.setToolTipText( + trans.get("simedtdlg.checkbox.ttip.Intowind1") + + trans.get("simedtdlg.checkbox.ttip.Intowind2") + + trans.get("simedtdlg.checkbox.ttip.Intowind3") + + trans.get("simedtdlg.checkbox.ttip.Intowind4")); + sub.add(checkWind, "spanx, wrap unrel"); + // Angle: label = new JLabel(trans.get("simedtdlg.lbl.Angle")); @@ -362,7 +374,7 @@ public class SimulationConditionsPanel extends JPanel { sub.add(label); m = new DoubleModel(conditions, "LaunchRodAngle", UnitGroup.UNITS_ANGLE, - 0, SimulationOptions.MAX_LAUNCH_ROD_ANGLE); + -SimulationOptions.MAX_LAUNCH_ROD_ANGLE, SimulationOptions.MAX_LAUNCH_ROD_ANGLE); spin = new JSpinner(m.getSpinnerModel()); spin.setEditor(new SpinnerEditor(spin)); @@ -372,7 +384,7 @@ public class SimulationConditionsPanel extends JPanel { unit = new UnitSelector(m); unit.setToolTipText(tip); sub.add(unit, "growx"); - slider = new BasicSlider(m.getSliderModel(0, Math.PI / 9, + slider = new BasicSlider(m.getSliderModel(-SimulationOptions.MAX_LAUNCH_ROD_ANGLE, 0, SimulationOptions.MAX_LAUNCH_ROD_ANGLE)); slider.setToolTipText(tip); sub.add(slider, "w 75lp, wrap"); @@ -381,19 +393,17 @@ public class SimulationConditionsPanel extends JPanel { // Direction: label = new JLabel(trans.get("simedtdlg.lbl.Direction")); - //// Direction of the launch rod relative to the wind.
- //// = towards the wind, - //// = downwind. + //// Direction of the launch rod. tip = trans.get("simedtdlg.lbl.ttip.Direction1") + UnitGroup.UNITS_ANGLE.toStringUnit(0) + " " + trans.get("simedtdlg.lbl.ttip.Direction2") + " " + - UnitGroup.UNITS_ANGLE.toStringUnit(Math.PI) + + UnitGroup.UNITS_ANGLE.toStringUnit(2*Math.PI) + " " + trans.get("simedtdlg.lbl.ttip.Direction3"); label.setToolTipText(tip); sub.add(label); - m = new DoubleModel(conditions, "LaunchRodDirection", UnitGroup.UNITS_ANGLE, - -Math.PI, Math.PI); + m = new DoubleModel(conditions, "LaunchRodDirection", 1.0, UnitGroup.UNITS_ANGLE, + 0, 2*Math.PI); spin = new JSpinner(m.getSpinnerModel()); spin.setEditor(new SpinnerEditor(spin)); @@ -403,10 +413,11 @@ public class SimulationConditionsPanel extends JPanel { unit = new UnitSelector(m); unit.setToolTipText(tip); sub.add(unit, "growx"); - slider = new BasicSlider(m.getSliderModel(-Math.PI, Math.PI)); + slider = new BasicSlider(m.getSliderModel(0, 2*Math.PI)); slider.setToolTipText(tip); sub.add(slider, "w 75lp, wrap"); + JButton restoreDefaults = new JButton(trans.get("simedtdlg.but.resettodefault")); restoreDefaults.addActionListener(new ActionListener() { From 0d829c1c6bf11fcb55eb331aac3fd8ce40201ca9 Mon Sep 17 00:00:00 2001 From: Craig Earls Date: Sun, 21 Dec 2014 20:56:15 -0700 Subject: [PATCH 3/3] Wind and Launch rod decoupled. Initial UI complete --- .../simulation/SimulationOptions.java | 8 +++++- .../simulation/SimulationConditionsPanel.java | 27 ++++++++++++------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/core/src/net/sf/openrocket/simulation/SimulationOptions.java b/core/src/net/sf/openrocket/simulation/SimulationOptions.java index ba8110cd7..b1a16c18a 100644 --- a/core/src/net/sf/openrocket/simulation/SimulationOptions.java +++ b/core/src/net/sf/openrocket/simulation/SimulationOptions.java @@ -65,12 +65,12 @@ public class SimulationOptions implements ChangeSource, Cloneable { private double launchRodAngle = 0; /** Launch rod direction, 0 = north. */ + private double windDirection = Math.PI / 2; private double launchRodDirection = 0; private double windAverage = 2.0; private double windTurbulence = 0.1; - private double windDirection = Math.PI / 2; /* * SimulationOptions maintains the launch site parameters as separate double values, @@ -163,6 +163,9 @@ public class SimulationOptions implements ChangeSource, Cloneable { public double getLaunchRodDirection() { + if (launchIntoWind) { + this.setLaunchRodDirection(windDirection); + } return launchRodDirection; } @@ -229,6 +232,9 @@ public class SimulationOptions implements ChangeSource, Cloneable { public void setWindDirection(double direction) { direction = MathUtil.reduce360(direction); + if (launchIntoWind) { + this.setLaunchRodDirection(direction); + } if (MathUtil.equals(this.windDirection, direction)) return; this.windDirection = direction; diff --git a/swing/src/net/sf/openrocket/gui/simulation/SimulationConditionsPanel.java b/swing/src/net/sf/openrocket/gui/simulation/SimulationConditionsPanel.java index 0ba49a3fc..67c033426 100644 --- a/swing/src/net/sf/openrocket/gui/simulation/SimulationConditionsPanel.java +++ b/swing/src/net/sf/openrocket/gui/simulation/SimulationConditionsPanel.java @@ -392,30 +392,37 @@ public class SimulationConditionsPanel extends JPanel { // Direction: - label = new JLabel(trans.get("simedtdlg.lbl.Direction")); + JLabel directionLabel = new JLabel(trans.get("simedtdlg.lbl.Direction")); //// Direction of the launch rod. tip = trans.get("simedtdlg.lbl.ttip.Direction1") + UnitGroup.UNITS_ANGLE.toStringUnit(0) + " " + trans.get("simedtdlg.lbl.ttip.Direction2") + " " + UnitGroup.UNITS_ANGLE.toStringUnit(2*Math.PI) + " " + trans.get("simedtdlg.lbl.ttip.Direction3"); - label.setToolTipText(tip); - sub.add(label); + directionLabel.setToolTipText(tip); + sub.add(directionLabel); m = new DoubleModel(conditions, "LaunchRodDirection", 1.0, UnitGroup.UNITS_ANGLE, 0, 2*Math.PI); - spin = new JSpinner(m.getSpinnerModel()); - spin.setEditor(new SpinnerEditor(spin)); - spin.setToolTipText(tip); - sub.add(spin, "w 65lp!"); + JSpinner directionSpin = new JSpinner(m.getSpinnerModel()); + directionSpin.setEditor(new SpinnerEditor(directionSpin)); + directionSpin.setToolTipText(tip); + sub.add(directionSpin, "w 65lp!"); unit = new UnitSelector(m); unit.setToolTipText(tip); sub.add(unit, "growx"); - slider = new BasicSlider(m.getSliderModel(0, 2*Math.PI)); - slider.setToolTipText(tip); - sub.add(slider, "w 75lp, wrap"); + BasicSlider directionSlider = new BasicSlider(m.getSliderModel(0, 2*Math.PI)); + directionSlider.setToolTipText(tip); + sub.add(directionSlider, "w 75lp, wrap"); + intoWind.addEnableComponent(directionLabel, false); + intoWind.addEnableComponent(directionSpin, false); + intoWind.addEnableComponent(unit, false); + intoWind.addEnableComponent(directionSlider, false); + + + JButton restoreDefaults = new JButton(trans.get("simedtdlg.but.resettodefault"));