summaryrefslogtreecommitdiff
path: root/grapher/Models
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-09-22 02:28:35 -0700
committerJacob Palecki <[email protected]>2020-09-22 02:28:35 -0700
commit8e58892723ee10792c7d3db275da826f98d01677 (patch)
tree25d5c35fba0734f891737aa038e882f318296353 /grapher/Models
parentMerge remote-tracking branch 'upstream/Experiment' into GUI (diff)
downloadrawaccel-8e58892723ee10792c7d3db275da826f98d01677.tar.xz
rawaccel-8e58892723ee10792c7d3db275da826f98d01677.zip
Mostly works
Diffstat (limited to 'grapher/Models')
-rw-r--r--grapher/Models/Calculations/AccelCalculator.cs5
-rw-r--r--grapher/Models/Calculations/AccelChartData.cs2
-rw-r--r--grapher/Models/Charts/AccelCharts.cs5
-rw-r--r--grapher/Models/Charts/ChartState/ChartState.cs24
-rw-r--r--grapher/Models/Charts/ChartXY.cs16
-rw-r--r--grapher/Models/Mouse/PointData.cs4
-rw-r--r--grapher/Models/Options/AccelTypeOptions.cs7
-rw-r--r--grapher/Models/Options/ApplyOptions.cs4
8 files changed, 62 insertions, 5 deletions
diff --git a/grapher/Models/Calculations/AccelCalculator.cs b/grapher/Models/Calculations/AccelCalculator.cs
index 8865939..ab6e9de 100644
--- a/grapher/Models/Calculations/AccelCalculator.cs
+++ b/grapher/Models/Calculations/AccelCalculator.cs
@@ -64,6 +64,11 @@ namespace grapher.Models.Calculations
foreach (var magnitudeDatum in magnitudeData)
{
+ if (magnitudeDatum.magnitude <=0)
+ {
+ continue;
+ }
+
var output = accel.Accelerate(magnitudeDatum.x, magnitudeDatum.y, MeasurementTime);
var outMagnitude = Magnitude(output.Item1, output.Item2);
diff --git a/grapher/Models/Calculations/AccelChartData.cs b/grapher/Models/Calculations/AccelChartData.cs
index fbf1944..5225e08 100644
--- a/grapher/Models/Calculations/AccelChartData.cs
+++ b/grapher/Models/Calculations/AccelChartData.cs
@@ -54,7 +54,6 @@ namespace grapher.Models.Calculations
{
var velIdx = GetVelocityIndex(outVelocityValue);
- velIdx = Math.Min(velIdx, VelocityPoints.Count - 1);
values = (VelocityPoints.ElementAt(velIdx).Key, AccelPoints.ElementAt(velIdx).Value, GainPoints.ElementAt(velIdx).Value);
OutVelocityToPoints.Add(outVelocityValue, values);
return values;
@@ -81,6 +80,7 @@ namespace grapher.Models.Calculations
}
velIdx = Math.Min(velIdx, VelocityPoints.Count - 1);
+ velIdx = Math.Max(velIdx, 0);
return velIdx;
}
diff --git a/grapher/Models/Charts/AccelCharts.cs b/grapher/Models/Charts/AccelCharts.cs
index d22ab78..a0e99c8 100644
--- a/grapher/Models/Charts/AccelCharts.cs
+++ b/grapher/Models/Charts/AccelCharts.cs
@@ -149,6 +149,11 @@ namespace grapher
ChartState.Calculate(accel, settings);
}
+ public void SetLogarithmic(bool x, bool y)
+ {
+ ChartState.SetLogarithmic(x, y);
+ }
+
private static void SetupCharts(
ChartXY sensitivityChart,
ChartXY velocityChart,
diff --git a/grapher/Models/Charts/ChartState/ChartState.cs b/grapher/Models/Charts/ChartState/ChartState.cs
index ea67e83..e1c7d01 100644
--- a/grapher/Models/Charts/ChartState/ChartState.cs
+++ b/grapher/Models/Charts/ChartState/ChartState.cs
@@ -100,5 +100,29 @@ namespace grapher.Models.Charts.ChartState
GainChart.Hide();
form.Height = SensitivityChart.Height + borderHeight;
}
+
+ public void SetLogarithmic(bool x, bool y)
+ {
+ if (x)
+ {
+ ChartXY.SetLogarithmic(SensitivityChart.ChartX);
+ ChartXY.SetLogarithmic(GainChart.ChartX);
+ }
+ else
+ {
+ ChartXY.SetStandard(SensitivityChart.ChartX);
+ ChartXY.SetStandard(GainChart.ChartX);
+ }
+
+ if (y)
+ {
+ ChartXY.SetLogarithmic(SensitivityChart.ChartY);
+ ChartXY.SetLogarithmic(GainChart.ChartY);
+ }
+ {
+ ChartXY.SetStandard(SensitivityChart.ChartY);
+ ChartXY.SetStandard(GainChart.ChartY);
+ }
+ }
}
}
diff --git a/grapher/Models/Charts/ChartXY.cs b/grapher/Models/Charts/ChartXY.cs
index fdd0258..b17960b 100644
--- a/grapher/Models/Charts/ChartXY.cs
+++ b/grapher/Models/Charts/ChartXY.cs
@@ -132,6 +132,22 @@ namespace grapher
}
}
+ public static void SetLogarithmic(Chart chart)
+ {
+ chart.ChartAreas[0].AxisX.Minimum = 0.001;
+ chart.ChartAreas[0].AxisX.Maximum = 3500;
+ chart.ChartAreas[0].AxisY.Minimum = 0.001;
+ chart.ChartAreas[0].AxisY.Maximum = 10;
+ chart.ChartAreas[0].AxisX.IsLogarithmic = true;
+ chart.ChartAreas[0].AxisY.IsLogarithmic = true;
+ }
+
+ public static void SetStandard(Chart chart)
+ {
+ chart.ChartAreas[0].AxisX.IsLogarithmic = false;
+ chart.ChartAreas[0].AxisY.IsLogarithmic = false;
+ }
+
public void SetPointBinds(PointData combined, PointData x, PointData y)
{
CombinedPointData = combined;
diff --git a/grapher/Models/Mouse/PointData.cs b/grapher/Models/Mouse/PointData.cs
index 374c52e..e3f44ea 100644
--- a/grapher/Models/Mouse/PointData.cs
+++ b/grapher/Models/Mouse/PointData.cs
@@ -9,8 +9,8 @@ namespace grapher.Models.Mouse
public PointData()
{
Lock = new Object();
- X = new double[] { 0 };
- Y = new double[] { 0 };
+ X = new double[] { 0.01 };
+ Y = new double[] { 0.01 };
}
#endregion Constructors
diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs
index 6f547cd..ce5ec54 100644
--- a/grapher/Models/Options/AccelTypeOptions.cs
+++ b/grapher/Models/Options/AccelTypeOptions.cs
@@ -64,6 +64,7 @@ namespace grapher
#endregion Constructors
#region Properties
+ public AccelCharts AccelCharts { get; }
public Button WriteButton { get; }
@@ -180,8 +181,8 @@ namespace grapher
public void SetActiveValues(int index, AccelArgs args)
{
- var name = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value.Name;
- AccelTypeActiveValue.SetValue(name);
+ AccelerationType = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value;
+ AccelTypeActiveValue.SetValue(AccelerationType.Name);
Weight.SetActiveValue(args.weight);
Cap.SetActiveValues(args.gainCap, args.scaleCap, args.gainCap > 0);
@@ -189,6 +190,8 @@ namespace grapher
Acceleration.SetActiveValue(args.accel);
LimitOrExponent.SetActiveValue(args.exponent);
Midpoint.SetActiveValue(args.midpoint);
+
+ Layout();
}
public void ShowFull()
diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs
index 6ec9d31..720cb13 100644
--- a/grapher/Models/Options/ApplyOptions.cs
+++ b/grapher/Models/Options/ApplyOptions.cs
@@ -130,6 +130,10 @@ namespace grapher.Models.Options
settings.args.x,
settings.args.y,
settings.combineMagnitudes);
+
+ AccelCharts.SetLogarithmic(
+ OptionSetX.Options.AccelerationType.LogarithmicCharts,
+ OptionSetY.Options.AccelerationType.LogarithmicCharts);
}
public void OnWholeClicked(object sender, EventArgs e)