[chronojump] JumpsProfile now uses max jump (of sj, sjl, cmj, abk, dj) to compare instead of dj
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] JumpsProfile now uses max jump (of sj, sjl, cmj, abk, dj) to compare instead of dj
- Date: Thu, 24 Feb 2022 15:25:13 +0000 (UTC)
commit f64f6b387164487ec0cc4c78c8da4f2ea0b6fb30
Author: Xavier de Blas <xaviblas gmail com>
Date: Thu Feb 24 16:24:44 2022 +0100
JumpsProfile now uses max jump (of sj,sjl,cmj,abk,dj) to compare instead of dj
src/gui/cairo/jumpsProfile.cs | 48 +++++++++++++++++++---------------
src/jumpsProfile.cs | 61 ++++++++++++++++---------------------------
src/util.cs | 1 +
src/utilMath.cs | 10 +++++++
4 files changed, 60 insertions(+), 60 deletions(-)
---
diff --git a/src/gui/cairo/jumpsProfile.cs b/src/gui/cairo/jumpsProfile.cs
index 769becd9d..15e52b109 100644
--- a/src/gui/cairo/jumpsProfile.cs
+++ b/src/gui/cairo/jumpsProfile.cs
@@ -16,7 +16,7 @@
* 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) 2004-2020 Xavier de Blas <xaviblas gmail com>
+ * Copyright (C) 2004-2022 Xavier de Blas <xaviblas gmail com>
*/
using System;
@@ -84,9 +84,6 @@ public static class JumpsProfileGraph
}
//5 calculate sum
- //but is not needed, because sum has to be dja
- //so if we have sum = 1 we can plot grey areas when not all indexes are calculated
- //so later sum will be 1, now is ok to just show an error message
double sum = 0;
foreach(JumpsProfileIndex jpi in l_jpi)
if(jpi.Result >= 0)
@@ -105,27 +102,33 @@ public static class JumpsProfileGraph
*/
//6 plot arcs
+ double jpiSum = 0;
if(sum > 0 )
{
double acc = 0; //accumulated
- bool someIndexNotPositive = false; //is not positive if does not exist (need jumps)
or is negative
- foreach(JumpsProfileIndex jpi in l_jpi) {
- //double percent = 2 * jpi.Result / sum; //*2 to be in range 0*pi - 2*pi
- double percent = 2 * jpi.Result / 1; //*2 to be in range 0*pi - 2*pi
- //LogB.Information("percent: " + percent.ToString());
- if(percent > 0)
+ //get the total of the > 0 indexes
+ bool allIndexesPositive = true;
+ foreach(JumpsProfileIndex jpi in l_jpi)
+ {
+ if(jpi.Result > 0)
+ jpiSum += jpi.Result;
+ else
+ allIndexesPositive = false;
+ }
+
+ foreach(JumpsProfileIndex jpi in l_jpi)
+ {
+ if(jpi.Result > 0)
{
+ double jpiResultFixed = jpi.Result;
+ if(! allIndexesPositive)
+ jpiResultFixed = jpi.Result * 1.0 / jpiSum;
+
+ double percent = 2 * jpiResultFixed / 1; //*2 to be in range 0*pi -
2*pi
plotArc(200, 200, 150, acc -.5, acc + percent -.5, g, jpi.Color);
//-.5 to start at top of the pie
acc += percent;
- } else
- someIndexNotPositive = true;
- }
- if(someIndexNotPositive) //then draw in white to complete the circle
- {
- //Cairo.Color white90 = new Cairo.Color(233/256.0, 233/256.0, 233/256.0);
- Cairo.Color white100 = new Cairo.Color(1,1,1);
- plotArc(200, 200, 150, acc -.5, 2 -.5, g, white100); //-.5 to start at top of
the pie
+ }
}
//fix last radius line, because ClosePath has been disabled
@@ -141,9 +144,12 @@ public static class JumpsProfileGraph
//R seq(from=50,to=(350-24),length.out=5)
//[1] 50 119 188 257 326 #difference is 69
//g.SelectFontFace(font, Cairo.FontSlant.Normal, Cairo.FontWeight.Bold);
+
+ //8 draw rectangles at right
foreach(JumpsProfileIndex jpi in l_jpi)
{
- double percent = 100 * UtilAll.DivideSafe(jpi.Result, sum);
+ //double percent = 100 * UtilAll.DivideSafe(jpi.Result, sum);
+ double percent = 100 * UtilAll.DivideSafe(jpi.Result, jpiSum);
printText(legendX, y, 24, textHeight, Util.TrimDecimals(percent, 1) + jpi.Text, g,
false);
if(percent != 0)
drawRoundedRectangle (legendX, y+30 , Convert.ToInt32(2 * percent), 20, 4,
g, jpi.Color);
@@ -158,7 +164,7 @@ public static class JumpsProfileGraph
//g.SelectFontFace(font, Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
- //8 print errors (if any)
+ //9 print errors (if any)
g.SetSourceRGB(0.5, 0, 0);
y = 70;
foreach(JumpsProfileIndex jpi in l_jpi) {
@@ -170,7 +176,7 @@ public static class JumpsProfileGraph
y += 69;
}
- //9 dispose
+ //10 dispose
g.GetTarget().Dispose ();
g.Dispose ();
}
diff --git a/src/jumpsProfile.cs b/src/jumpsProfile.cs
index f6ea2a05f..785a93264 100644
--- a/src/jumpsProfile.cs
+++ b/src/jumpsProfile.cs
@@ -15,7 +15,7 @@
* 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) 2004-2017 Xavier de Blas <xaviblas gmail com>
+ * Copyright (C) 2004-2022 Xavier de Blas <xaviblas gmail com>
*/
using System;
@@ -38,70 +38,60 @@ public class JumpsProfileIndex
public double Result;
- public JumpsProfileIndex (Types type, string jumpHigherName, string jumpLowerName, double higher,
double lower, double dja)
+ public JumpsProfileIndex (Types type, string jumpHigherName, string jumpLowerName, double higher,
double lower, double max)
{
//colour palette: http://www.colourlovers.com/palette/4286628/Tabor_1
this.type = type;
switch(type) {
case Types.FMAX:
- Text = "% Maximum Force SJl100% / DJa";
+ Text = "% Maximum Force SJl100% / max";
Color = colorFromRGB(101,86,67);
break;
case Types.FEXPL:
- Text = "% Explosive Force (SJ - SJl100%) / Dja";
+ Text = "% Explosive Force (SJ - SJl100%) / max";
Color = colorFromRGB(209,63,58);
break;
case Types.CELAST:
- Text = "% Elastic (CMJ - SJ) / Dja";
+ Text = "% Elastic (CMJ - SJ) / max";
Color = colorFromRGB(255,152,68);
break;
case Types.CARMS:
- Text = "% Arms (ABK - CMJ) / Dja";
+ Text = "% Arms (ABK - CMJ) / max";
Color = colorFromRGB(141,237,78);
break;
case Types.FREACT:
- Text = "% Reactive-reflex (DJa - ABK) / Dja";
+ Text = "% Reactive-reflex (DJa - ABK) / max";
Color = colorFromRGB(133,190,199);
break;
default:
- Text = "% Maximum Force SJl100% / DJa";
+ Text = "% Maximum Force SJl100% / max";
Color = colorFromRGB(101,86,67);
break;
}
ErrorMessage = "";
- Result = calculateIndex(type, higher, lower, dja);
+ Result = calculateIndex(type, higher, lower, max);
LogB.Information("errorCode: " + errorCode.ToString());
if(errorCode == ErrorCodes.NEEDJUMP)
ErrorMessage = Catalog.GetString("Need to execute jump/s"); //TODO: write which jumps
else if(errorCode == ErrorCodes.NEGATIVE)
ErrorMessage = string.Format(Catalog.GetString("Negative index: {0} is higher than
{1}"), jumpLowerName, jumpHigherName);
- else if(errorCode == ErrorCodes.DJATOOLOW)
- ErrorMessage = string.Format(Catalog.GetString("Jump {0} too low"), "Dja");
+ //else if(errorCode == ErrorCodes.DJATOOLOW)
+ // ErrorMessage = string.Format(Catalog.GetString("Jump {0} too low"), "Dja");
}
- private double calculateIndex (Types type, double higher, double lower, double dja)
+ private double calculateIndex (Types type, double higher, double lower, double max)
{
errorCode = ErrorCodes.NONE_OK;
- if(dja == 0 || higher == 0) {
+ if(max == 0 || higher == 0) {
errorCode = ErrorCodes.NEEDJUMP;
return 0;
}
if(type == Types.FMAX) //this index only uses higher
- {
- if(higher > dja)
- {
- errorCode = ErrorCodes.DJATOOLOW;
- return 0;
- }
-
- LogB.Information(string.Format("calculateIndex, type:{0}, higher:{1}, lower:{2},
dja:{3}, value:{4}",
- type, higher, lower, dja, higher/dja));
- return higher / dja;
- }
+ return higher / max;
if(lower == 0) {
errorCode = ErrorCodes.NEEDJUMP;
@@ -113,16 +103,7 @@ public class JumpsProfileIndex
//return 0;
}
- if(higher > dja) // at least a jump is higher than DJa
- {
- errorCode = ErrorCodes.DJATOOLOW;
- return 0;
- }
-
- LogB.Information(string.Format("calculateIndex, type:{0}, higher:{1}, lower:{2}, dja:{3},
value:{4}",
- type, higher, lower, dja, (higher-lower)/dja));
-
- return (higher - lower) / dja;
+ return (higher - lower) / max;
}
private Cairo.Color colorFromRGB(int red, int green, int blue) {
@@ -156,11 +137,13 @@ public class JumpsProfile
double abk = l[3];
double dja = l[4];
- jpi0 = new JumpsProfileIndex(JumpsProfileIndex.Types.FMAX, "SJ", "", sjl, 0, dja);
- jpi1 = new JumpsProfileIndex(JumpsProfileIndex.Types.FEXPL, "SJ", "SJl", sj, sjl, dja);
- jpi2 = new JumpsProfileIndex(JumpsProfileIndex.Types.CELAST, "CMJ", "SJ", cmj, sj, dja);
- jpi3 = new JumpsProfileIndex(JumpsProfileIndex.Types.CARMS, "ABK", "CMJ", abk, cmj, dja);
- jpi4 = new JumpsProfileIndex(JumpsProfileIndex.Types.FREACT, "DJa", "ABK", dja, abk, dja);
+ double maxJump = MathUtil.GetMax (new List<double> { sj, sjl, cmj, abk, dja});
+
+ jpi0 = new JumpsProfileIndex(JumpsProfileIndex.Types.FMAX, "SJ", "", sjl, 0, maxJump);
+ jpi1 = new JumpsProfileIndex(JumpsProfileIndex.Types.FEXPL, "SJ", "SJl", sj, sjl, maxJump);
+ jpi2 = new JumpsProfileIndex(JumpsProfileIndex.Types.CELAST, "CMJ", "SJ", cmj, sj, maxJump);
+ jpi3 = new JumpsProfileIndex(JumpsProfileIndex.Types.CARMS, "ABK", "CMJ", abk, cmj, maxJump);
+ jpi4 = new JumpsProfileIndex(JumpsProfileIndex.Types.FREACT, "DJa", "ABK", dja, abk, maxJump);
fillListJumpsDone(sj, sjl, cmj, abk, dja);
}
diff --git a/src/util.cs b/src/util.cs
index 7fefa017c..0f54cb05e 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -199,6 +199,7 @@ public class Util
return Math.Round(Convert.ToDouble(time), prefsDigitsNumber).ToString();
}
+ //for List of doubles better use MathUtil class (utilMath.cs)
public static double GetMax (string values)
{
string [] myStringFull = values.Split(new char[] {'='});
diff --git a/src/utilMath.cs b/src/utilMath.cs
index fcd251619..02fd66fd5 100644
--- a/src/utilMath.cs
+++ b/src/utilMath.cs
@@ -600,6 +600,16 @@ public static class MathUtil
return ( Math.Abs(criteriaPassedValue - numToCompare) <= Math.Abs(previousToCriteriaValue -
numToCompare) );
}
+ public static double GetMax (List<double> d_l)
+ {
+ double max = 0;
+ foreach (double d in d_l)
+ if ( d > max )
+ max = d;
+
+ return max;
+ }
+
}
public class InterpolateSignal
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]