[chronojump] jumpsDjOptimalFallingHeight for upcoming optimal falling height prediction



commit 755bbf77b7e412f45276b60fe5b8cd82fe661d2c
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Dec 11 13:20:25 2019 +0100

    jumpsDjOptimalFallingHeight for upcoming optimal falling height prediction

 src/Makefile.am                    |  1 +
 src/gui/app1/chronojump.cs         |  9 ++++--
 src/jumpsDjOptimalFallingHeight.cs | 56 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 2 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index e599680b..9c761954 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -172,6 +172,7 @@ SOURCES = \
        json/exhibitions.cs\
        jump.cs\
        jumpsProfile.cs\
+       jumpsDjOptimalFallingHeight.cs\
        jumpType.cs\
        networks.cs\
        person.cs\
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index abdcb98f..4b0d5519 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -6854,8 +6854,13 @@ LogB.Debug("mc finished 5");
        
        private void on_button_carles_clicked (object o, EventArgs args)
        {
-               if (currentPerson == null || currentSession == null) return;
-               SqliteJump.SelectDJa (currentPerson.UniqueID, currentSession.UniqueID);
+               if (currentPerson == null || currentSession == null)
+                       return;
+
+               JumpsDjOptimalFallingHeight jdofh = new JumpsDjOptimalFallingHeight();
+               jdofh.Calculate(currentPerson.UniqueID, currentSession.UniqueID);
+
+
                /*
                bool showInWindow = true;
 
diff --git a/src/jumpsDjOptimalFallingHeight.cs b/src/jumpsDjOptimalFallingHeight.cs
new file mode 100644
index 00000000..1db75e60
--- /dev/null
+++ b/src/jumpsDjOptimalFallingHeight.cs
@@ -0,0 +1,56 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  Copyright (C) 2019   Xavier de Blas <xaviblas gmail com>, Jordi Rodeiro <jordirodeiro gmail com>
+ */
+
+using System;
+using System.Collections.Generic; //List
+
+public class JumpsDjOptimalFallingHeight
+{
+       //constructor
+       public JumpsDjOptimalFallingHeight()
+       {
+       }
+       
+       public void Calculate (int personID, int sessionID)
+       {
+               //1 get data
+                List<Jump> jump_l = SqliteJump.SelectDJa (personID, sessionID);
+
+               //2 convert to list of Point
+               List<Point> point_l = new List<Point>();
+                foreach(Jump j in jump_l)
+                       point_l.Add(new Point(
+                                               j.Fall,
+                                               Util.GetHeightInCentimeters(j.Tv)
+                                               ));
+
+               //3 get LeastSquares
+               LeastSquares ls = new LeastSquares();
+               ls.Calculate(point_l);
+
+               //4 print data
+               if(ls.CalculatedCoef)
+                       LogB.Information(string.Format("coef = {0} {1} {2}",
+                                               ls.Coef[0], ls.Coef[1], ls.Coef[2]));
+
+               if(ls.CalculatedMaxY)
+                       LogB.Information(string.Format("MaxY = {0}", ls.MaxY));
+       }
+}


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