[chronojump/michrolab] GetPower GetDjPower moved from util.cs to jump.cs



commit da5a3660a93ed844b6550cc3bdd0547b926d3515
Author: Xavier de Blas <xaviblas gmail com>
Date:   Thu Aug 4 13:27:29 2022 +0200

    GetPower GetDjPower moved from util.cs to jump.cs

 src/exportSession.cs |  4 ++--
 src/jump.cs          | 37 ++++++++++++++++++++++++++++++++++++-
 src/treeview/jump.cs | 12 ++++++------
 src/util.cs          | 36 ------------------------------------
 4 files changed, 44 insertions(+), 45 deletions(-)
---
diff --git a/src/exportSession.cs b/src/exportSession.cs
index ac9a53552..cc4cf3e0c 100644
--- a/src/exportSession.cs
+++ b/src/exportSession.cs
@@ -292,9 +292,9 @@ public class ExportSession
                int dec = preferences.digitsNumber; //decimals
                if(tf > 0) {    
                        if(tc > 0)              //dj
-                               return Util.TrimDecimals(Util.GetDjPower(tc, tf, (personWeight + 
extraWeightInKg), fall).ToString(), dec);
+                               return Util.TrimDecimals (Jump.GetDjPower(tc, tf, (personWeight + 
extraWeightInKg), fall).ToString(), dec);
                        else                    //it's a simple jump without tc
-                               return Util.TrimDecimals(Util.GetPower(tf, personWeight, 
extraWeightInKg).ToString(), dec);
+                               return Util.TrimDecimals (Jump.GetPower(tf, personWeight, 
extraWeightInKg).ToString(), dec);
                }
                return "-";
        }
diff --git a/src/jump.cs b/src/jump.cs
index c483a0000..636282d6d 100644
--- a/src/jump.cs
+++ b/src/jump.cs
@@ -91,7 +91,42 @@ public class Jump : Event
                                weight, description, 
                                angle, simulated, datetime);
        }
-       
+
+       public static double GetDjPower (double tc, double tf, double mass, double fallHeight)
+       {
+               /*
+                * old method
+               //relative potency in Watts/Kg
+               //Bosco. Pendent to find if published
+
+               //P = 24.6 * (TotalTime + FlightTime) / ContactTime
+
+               double tt = tc + tf; //totalTime
+
+               return 24.6 * ( tt + tf ) / (Double)tc;
+               */
+
+               //new method (proposal by Xavier Padullés)
+               //Calcule the potential energies before (mass * g * fallHeight) and after the jump (mass * g 
* tv^2 * 1.226)
+               //and divide by the time during force is applied
+               double g = 9.81;
+               fallHeight = fallHeight / 100.0; //cm -> m
+
+               return mass * g * ( fallHeight + 1.226 * Math.Pow(tf,2) ) / (Double)tc;
+       }
+
+       //only Lewis now
+       public static double GetPower (double tf, double bodyWeight, double extraWeightKg)
+       {
+               //Log.WriteLine("tf: " + tf + ", bodyWeight: " + bodyWeight + ", extra: " + extraWeightKg);
+               double pw = System.Math.Sqrt ( 4.9 ) * 9.8 * (bodyWeight + extraWeightKg) *
+                       System.Math.Sqrt(
+                                      Convert.ToDouble ( Util.GetHeightInCentimeters(tf.ToString()))/100);
+               //Log.WriteLine("pw: " + pw);
+               return pw;
+
+       }
+
        public virtual double Stiffness(double personMassInKg, double extraMass) 
        {
                return Util.GetStiffness(personMassInKg, extraMass, tv, tc);
diff --git a/src/treeview/jump.cs b/src/treeview/jump.cs
index 86e05beb9..2f250c174 100644
--- a/src/treeview/jump.cs
+++ b/src/treeview/jump.cs
@@ -219,10 +219,10 @@ public class TreeViewJumps : TreeViewEvent
                        if(newJump.Tv > 0) {    
                                if(newJump.Tc > 0)      //if it's Dj (has tf, and tc)
                                        myData[count++] = Util.TrimDecimals(
-                                                       Util.GetDjPower(newJump.Tc, newJump.Tv, (personWeight 
+ weightInKg), newJump.Fall).ToString(), 1);
+                                                       Jump.GetDjPower (newJump.Tc, newJump.Tv, 
(personWeight + weightInKg), newJump.Fall).ToString(), 1);
                                else {                  //it's a simple jump without tc
                                        myData[count++] = Util.TrimDecimals(
-                                                       Util.GetPower(newJump.Tv, personWeight, 
weightInKg).ToString(), 1);
+                                                       Jump.GetPower (newJump.Tv, personWeight, 
weightInKg).ToString(), 1);
                                }
                        } else
                                myData[count++] = "0";
@@ -402,11 +402,11 @@ public class TreeViewJumpsRj : TreeViewJumps
                        
                        if(Convert.ToDouble(thisTc) > 0)
                                myData[count++] = Util.TrimDecimals(
-                                               Util.GetDjPower(thisTcD, thisTvD,
+                                               Jump.GetDjPower (thisTcD, thisTvD,
                                                        (personWeight + weightInKg), myFall).ToString(), 1);
                        else
                                myData[count++] = Util.TrimDecimals(
-                                               Util.GetPower(thisTvD, personWeight, weightInKg).ToString(), 
1);
+                                               Jump.GetPower (thisTvD, personWeight, weightInKg).ToString(), 
1);
                }
                if (preferences.showStiffness) {
                        //use directly Util.GetStiffness because we want to get from this specific subjump, 
not all the reactive jump.
@@ -533,13 +533,13 @@ public class TreeViewJumpsRj : TreeViewJumps
                                double tv = Convert.ToDouble(tv_array[i]);
                                double fall = 0;
                                if(tc_array[i] == "-1") //startIn at first jump tc is 0, better check like 
this (string)
-                                       powerSum += Util.GetPower(tv, personWeight, weightInKg);
+                                       powerSum += Jump.GetPower (tv, personWeight, weightInKg);
                                else {
                                        if(i == 0)
                                                fall = newJumpRj.Fall;
                                        else
                                                fall = 
Util.GetHeightInCentimeters(Convert.ToDouble(tv_array[i-1]));
-                                       powerSum += Util.GetDjPower(tc, tv,
+                                       powerSum += Jump.GetDjPower (tc, tv,
                                                        (personWeight + weightInKg), fall);
                                        stiffnessSum += Util.GetStiffness(personWeight, weightInKg, tv, tc);
                                        stiffnessCount ++;
diff --git a/src/util.cs b/src/util.cs
index 0cd2772bc..e585a6171 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -804,42 +804,6 @@ public class Util
                return Math.Sqrt( (9.81 * jumpHeightM) / 2);
        }
        
-       public static double GetDjPower (double tc, double tf, double mass, double fallHeight) 
-       {
-               /*
-                * old method
-               //relative potency in Watts/Kg
-               //Bosco. Pendent to find if published
-
-               //P = 24.6 * (TotalTime + FlightTime) / ContactTime
-
-               double tt = tc + tf; //totalTime
-
-               return 24.6 * ( tt + tf ) / (Double)tc;
-               */
-
-               //new method (proposal by Xavier Padullés)
-               //Calcule the potential energies before (mass * g * fallHeight) and after the jump (mass * g 
* tv^2 * 1.226)
-               //and divide by the time during force is applied
-               double g = 9.81;
-               fallHeight = fallHeight / 100.0; //cm -> m
-               
-               return mass * g * ( fallHeight + 1.226 * Math.Pow(tf,2) ) / (Double)tc;
-       }
-                               
-       //only Lewis now
-       public static double GetPower (double tf, double bodyWeight, double extraWeightKg) 
-       {
-               //Log.WriteLine("tf: " + tf + ", bodyWeight: " + bodyWeight + ", extra: " + extraWeightKg);
-               double pw = System.Math.Sqrt ( 4.9 ) * 9.8 * (bodyWeight + extraWeightKg) *
-                       System.Math.Sqrt(
-                                      Convert.ToDouble(GetHeightInCentimeters(tf.ToString()))/100);
-               //Log.WriteLine("pw: " + pw);
-               return pw;
-
-       }
-
-
        public static double GetQIndex (double tv, double tc) 
        {
                if(tv == 0 || tc == 0)


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