[chronojump] CairoGraphRaceAnalyzer prints RunEncoderSegmentCalcs power
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] CairoGraphRaceAnalyzer prints RunEncoderSegmentCalcs power
- Date: Mon, 9 May 2022 10:56:13 +0000 (UTC)
commit e5c0d6ac6a4ad314a9390fdd91e6ac28f2f78adb
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon May 9 12:55:57 2022 +0200
CairoGraphRaceAnalyzer prints RunEncoderSegmentCalcs power
src/gui/cairo/raceAnalyzer.cs | 7 ++++---
src/runEncoder.cs | 14 +++++++++++---
2 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/src/gui/cairo/raceAnalyzer.cs b/src/gui/cairo/raceAnalyzer.cs
index aa00ff3d6..89471f7f9 100644
--- a/src/gui/cairo/raceAnalyzer.cs
+++ b/src/gui/cairo/raceAnalyzer.cs
@@ -136,7 +136,7 @@ public class CairoGraphRaceAnalyzer : CairoXY
//vertical
if(segmentCalcs.Count > 0)
{
- LogB.Information("accels ; forces");
+ LogB.Information("accels ; forces ; powers");
g.Save();
g.SetDash(new double[]{1, 2}, 0);
for(int i = 0 ; i < segmentCalcs.Count ; i ++)
@@ -146,9 +146,10 @@ public class CairoGraphRaceAnalyzer : CairoXY
//seconds
string xTextBottom =
Util.TrimDecimals(segmentCalcs.Time_l[i]/1000000.0, 1).ToString();
double xGraph =
calculatePaintX(segmentCalcs.Time_l[i]/1000000.0);
- LogB.Information(string.Format("{0} ; {1}",
+ LogB.Information(string.Format("{0} ; {1}; {2}",
segmentCalcs.Accel_l[i].ToString(),
- segmentCalcs.Force_l[i].ToString() ));
+ segmentCalcs.Force_l[i].ToString(),
+ segmentCalcs.Power_l[i].ToString() ));
if(useListOfDoublesOnY)
paintVerticalGridLine(g, Convert.ToInt32(xGraph),
xTextBottom, textHeight-3);
diff --git a/src/runEncoder.cs b/src/runEncoder.cs
index 86e548ae0..1fae91ec0 100644
--- a/src/runEncoder.cs
+++ b/src/runEncoder.cs
@@ -418,8 +418,8 @@ public class RunEncoderSegmentCalcs
private List<double> speedCont_l;
private List<double> accel_l;
private List<double> force_l;
+ private List<double> power_l;
/*
- //TODO: a, F, P
accel = (V2 - V1)/(T2 - T1)
F = m * (a + g*sin(alpha))
P = 0.5 * m * (V2^2 - V1^2) + m*g*(h2 - h1)
@@ -440,7 +440,7 @@ public class RunEncoderSegmentCalcs
speedCont_l = new List<double> ();
accel_l = new List<double> ();
force_l = new List<double> ();
- //TODO: a, F, P
+ power_l = new List<double> ();
}
//speedCont is continuous (at this instant) (no avg: dist/time of the segment)
@@ -458,11 +458,12 @@ public class RunEncoderSegmentCalcs
double accel = UtilAll.DivideSafe(speedCont, time/1000000.0);
accel_l.Add (accel);
force_l.Add ( massKg * (accel + g * Math.Sin(angle)) );
+ power_l.Add ( 0.5 * massKg * Math.Pow(speedCont, 2) + massKg * g * (dist *
Math.Sin(angle)) );
}
else
{
/*
- debug:
+ debug accel:
LogB.Information(string.Format("speed now: {0}, speed pre: {1}, time now: {2}, time
pre: {3}, result: {4}",
speedCont, speedCont_l[Count -2], time/1000000.0,
time_l[Count -2]/1000000.0,
UtilAll.DivideSafe( (speedCont - speedCont_l[Count -2]),
(time/1000000.0 - time_l[Count -2]/1000000.0) ) ));
@@ -472,6 +473,10 @@ public class RunEncoderSegmentCalcs
(speedCont - speedCont_l[Count -2]), (time/1000000.0 - time_l[Count
-2]/1000000.0) );
accel_l.Add (accel);
force_l.Add ( massKg * (accel + g * Math.Sin(angle)) );
+ power_l.Add ( 0.5 * massKg *
+ (Math.Pow(speedCont, 2) - Math.Pow(speedCont_l[Count -2], 2)) +
+ massKg * g * (dist * Math.Sin(angle) - dist_l[Count -2] *
Math.Sin(angle))
+ );
}
}
@@ -492,6 +497,9 @@ public class RunEncoderSegmentCalcs
public List<double> Force_l {
get { return force_l; }
}
+ public List<double> Power_l {
+ get { return power_l; }
+ }
}
public class RunEncoderExercise
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]