[chronojump] forceSensorAnalyze manual with impulse



commit 8470012a4342d6e774edd88cedd9d97c6cd602f1
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue May 8 01:22:57 2018 +0200

    forceSensorAnalyze manual with impulse

 src/forceSensor.cs            |   18 ++++++++++++++++++
 src/gui/forceSensorAnalyze.cs |   16 ++++++++++++++--
 2 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/src/forceSensor.cs b/src/forceSensor.cs
index 5767693..9ec01b8 100644
--- a/src/forceSensor.cs
+++ b/src/forceSensor.cs
@@ -165,6 +165,19 @@ public class ForceSensorCapturePoints
                //      countA, countB, forces[countA], forces[countB], times[countA], times[countB], calc));
                return calc;
        }
+       public double GetImpulse(int countA, int countB)
+       {
+               double sum = 0;
+               int samples = 0;
+               for(int i = countA; i <= countB; i ++)
+               {
+                       sum += forces[i];
+                       samples ++;
+               }
+
+               double elapsedSeconds = times[countB]/1000000.0 - times[countA]/1000000.0;
+               return sum * Util.DivideSafe(elapsedSeconds, samples);
+       }
        public int MarginLeft
        {
                get { return marginLeft; }
@@ -722,6 +735,11 @@ public class ForceSensorAnalyzeInstant
                return fscAIPoints.GetRFD(countA, countB);
        }
 
+       public double CalculateImpulse(int countA, int countB)
+       {
+               return fscAIPoints.GetImpulse(countA, countB);
+       }
+
        /*
         * Calculates RFD in a point using previous and next point
         */
diff --git a/src/gui/forceSensorAnalyze.cs b/src/gui/forceSensorAnalyze.cs
index 85fe0f3..ae1fb31 100644
--- a/src/gui/forceSensorAnalyze.cs
+++ b/src/gui/forceSensorAnalyze.cs
@@ -769,7 +769,7 @@ public partial class ChronoJumpWindow
                        textHeight = 1;
                        layout_force_ai_text.GetPixelSize(out textWidth, out textHeight);
                        force_sensor_ai_pixmap.DrawLayout (pen_blue_force_ai,
-                                       allocation.Width -textWidth -10, allocation.Height/2 -20,
+                                       allocation.Width -textWidth -10, allocation.Height/2 -40,
                                        layout_force_ai_text);
 
                        // 8) calculate and paint max RFD
@@ -786,7 +786,7 @@ public partial class ChronoJumpWindow
 
                        layout_force_ai_text.GetPixelSize(out textWidth, out textHeight);
                        force_sensor_ai_pixmap.DrawLayout (pen_red_force_ai,
-                                       allocation.Width -textWidth -10, allocation.Height/2,
+                                       allocation.Width -textWidth -10, allocation.Height/2 -20,
                                        layout_force_ai_text);
 
 
@@ -825,6 +825,18 @@ public partial class ChronoJumpWindow
                        force_sensor_ai_pixmap.DrawLine(pen_red_force_ai,
                                        lineXA, lineYA,
                                        lineXB, lineYB);
+
+                       // 9) calculate and paint impulse
+                       layout_force_ai_text.SetMarkup(string.Format("Impulse: {0:0.#} N*s",
+                                               Math.Round(fsAI.CalculateImpulse(
+                                                               hscaleLower, hscaleHigher), 1) ));
+
+                       layout_force_ai_text.GetPixelSize(out textWidth, out textHeight);
+                       force_sensor_ai_pixmap.DrawLayout (pen_black_force_ai,
+                                       allocation.Width -textWidth -10, allocation.Height/2,
+                                       layout_force_ai_text);
+
+
                }
                LogB.Information("forceSensorAnalyzeManualGraphDo() END");
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]