[chronojump] UtilMath.Point renamed UtilMath.PointF



commit e6a71338813843378da8ec1ff0cf41954350b3d1
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jan 31 16:29:39 2020 +0100

    UtilMath.Point renamed UtilMath.PointF

 src/gui/cairo/jumpsDjOptimalFall.cs   |  2 +-
 src/gui/cairo/jumpsEvolution.cs       |  2 +-
 src/gui/cairo/jumpsWeightFVProfile.cs |  2 +-
 src/gui/cairo/xy.cs                   | 18 +++++++++---------
 src/jumpsDjOptimalFall.cs             | 10 +++++-----
 src/jumpsEvolution.cs                 | 12 ++++++------
 src/jumpsWeightFVProfile.cs           | 14 +++++++-------
 src/utilMath.cs                       | 32 ++++++++++++++++++++------------
 8 files changed, 50 insertions(+), 42 deletions(-)
---
diff --git a/src/gui/cairo/jumpsDjOptimalFall.cs b/src/gui/cairo/jumpsDjOptimalFall.cs
index 676652e5..9e5e3d6f 100644
--- a/src/gui/cairo/jumpsDjOptimalFall.cs
+++ b/src/gui/cairo/jumpsDjOptimalFall.cs
@@ -44,7 +44,7 @@ public class JumpsDjOptimalFallGraph : CairoXY
 
        //regular constructor
        public JumpsDjOptimalFallGraph (
-                       List<Point> point_l, double[] coefs,
+                       List<PointF> point_l, double[] coefs,
                        LeastSquaresParabole.ParaboleTypes paraboleType,
                        double xAtMMaxY, //x at Model MaxY
                        double pointsMaxValue,
diff --git a/src/gui/cairo/jumpsEvolution.cs b/src/gui/cairo/jumpsEvolution.cs
index 446c8ea7..79812b9a 100644
--- a/src/gui/cairo/jumpsEvolution.cs
+++ b/src/gui/cairo/jumpsEvolution.cs
@@ -43,7 +43,7 @@ public class JumpsEvolutionGraph : CairoXY
 
        //regular constructor
        public JumpsEvolutionGraph (
-                       List<Point> point_l, double slope, double intercept,
+                       List<PointF> point_l, double slope, double intercept,
                        DrawingArea area, string title, string jumpType, string date)
        {
                this.point_l = point_l;
diff --git a/src/gui/cairo/jumpsWeightFVProfile.cs b/src/gui/cairo/jumpsWeightFVProfile.cs
index 1edccfb3..55f4949f 100644
--- a/src/gui/cairo/jumpsWeightFVProfile.cs
+++ b/src/gui/cairo/jumpsWeightFVProfile.cs
@@ -53,7 +53,7 @@ public class JumpsWeightFVProfileGraph : CairoXY
 
        //regular constructor
        public JumpsWeightFVProfileGraph (
-                       List<Point> point_l, double slope, double intercept,
+                       List<PointF> point_l, double slope, double intercept,
                        DrawingArea area, string title, //string jumpType,
                        string date)
        {
diff --git a/src/gui/cairo/xy.cs b/src/gui/cairo/xy.cs
index 4d03ae70..695a9586 100644
--- a/src/gui/cairo/xy.cs
+++ b/src/gui/cairo/xy.cs
@@ -27,7 +27,7 @@ using Cairo;
 public abstract class CairoXY
 {
        //used on construction
-       protected List<Point> point_l;
+       protected List<PointF> point_l;
        protected bool predictedPointDone;
 
        //regression line straight
@@ -105,7 +105,7 @@ public abstract class CairoXY
 
        protected void findPointMaximums()
        {
-               foreach(Point p in point_l)
+               foreach(PointF p in point_l)
                {
                        if(p.X < minX)
                                minX = p.X;
@@ -243,7 +243,7 @@ public abstract class CairoXY
 
        protected void plotRealPoints()
        {
-               foreach(Point p in point_l)
+               foreach(PointF p in point_l)
                {
                        LogB.Information(string.Format("point: {0}", p));
                        double xgraph = calculatePaintX(p.X);
@@ -360,7 +360,7 @@ public abstract class CairoXY
                */
 
                // 3) find closest point (including predicted point if any)
-               Point pClosest = findClosestGraphPoint(graphX, graphY);
+               PointF pClosest = findClosestGraphPoint(graphX, graphY);
 
                // 4) write text at right
                writeTextAtRight(line, "Selected:", false);
@@ -378,11 +378,11 @@ public abstract class CairoXY
         * using graphPoints and not real points because X and Y scale can be very different
         * and this would be stranger for user to have a point selected far away to the "graph" closest point
         */
-       private Point findClosestGraphPoint(double graphX, double graphY)
+       private PointF findClosestGraphPoint(double graphX, double graphY)
        {
                double distMin = 10000000;
-               Point pClosest = point_l[0];
-               foreach(Point p in point_l)
+               PointF pClosest = point_l[0];
+               foreach(PointF p in point_l)
                {
                        double dist = Math.Sqrt(Math.Pow(graphX - calculatePaintX(p.X), 2) + Math.Pow(graphY 
- calculatePaintY(p.Y), 2));
                        if(dist < distMin)
@@ -394,7 +394,7 @@ public abstract class CairoXY
 
                //also check predicted point if exits
                if(predictedPointDone && Math.Sqrt(Math.Pow(graphX - calculatePaintX(xAtMMaxY), 2) + 
Math.Pow(graphY - calculatePaintY(yAtMMaxY), 2)) < distMin)
-                       pClosest = new Point(xAtMMaxY, yAtMMaxY);
+                       pClosest = new PointF(xAtMMaxY, yAtMMaxY);
 
                return pClosest;
        }
@@ -602,7 +602,7 @@ public abstract class CairoXY
                int count = 0;
                //note p.X is jump fall and p.Y jump height
                //TODO: maybe this will be for a legend, because the graph wants X,Y points
-               foreach(Point p in point_l)
+               foreach(PointF p in point_l)
                {
                        int x = Convert.ToInt32((graphWidth - 
rightMargin)*(count+.5)/point_l.Count)-barDesplLeft;
                        int y = calculatePaintY(Convert.ToDouble(p.X), graphHeight, pointsMaxValue, 0, 
topMargin, bottomMargin + bottomAxis);
diff --git a/src/jumpsDjOptimalFall.cs b/src/jumpsDjOptimalFall.cs
index c04bc4df..e28969a4 100644
--- a/src/jumpsDjOptimalFall.cs
+++ b/src/jumpsDjOptimalFall.cs
@@ -23,7 +23,7 @@ using System.Collections.Generic; //List
 
 public class JumpsDjOptimalFall
 {
-       private List<Point> point_l;
+       private List<PointF> point_l;
        LeastSquaresParabole ls;
 
        //constructor
@@ -38,9 +38,9 @@ public class JumpsDjOptimalFall
 
                //2 convert to list of Point
                //List<Point> point_l = new List<Point>();
-               point_l = new List<Point>();
+               point_l = new List<PointF>();
                 foreach(Jump j in jump_l)
-                       point_l.Add(new Point(
+                       point_l.Add(new PointF(
                                                j.Fall,
                                                Util.GetHeightInCentimeters(j.Tv)
                                                ));
@@ -61,7 +61,7 @@ public class JumpsDjOptimalFall
        public double GetMaxValue()
        {
                double maxValue = 0;
-                foreach(Point p in point_l)
+                foreach(PointF p in point_l)
                {
                        if(p.X > maxValue)
                                maxValue = p.X;
@@ -72,7 +72,7 @@ public class JumpsDjOptimalFall
                return maxValue;
        }
 
-       public List<Point> Point_l
+       public List<PointF> Point_l
        {
                get { return point_l; }
        }
diff --git a/src/jumpsEvolution.cs b/src/jumpsEvolution.cs
index 0d2e2093..6f74bb02 100644
--- a/src/jumpsEvolution.cs
+++ b/src/jumpsEvolution.cs
@@ -25,7 +25,7 @@ using System.Collections.Generic; //List
 
 public class JumpsEvolution
 {
-       private List<Point> point_l;
+       private List<PointF> point_l;
        LeastSquaresLine ls;
 
        //constructor
@@ -38,14 +38,14 @@ public class JumpsEvolution
                //1 get data
                 List<Jump> jump_l = SqliteJump.SelectJumps (personID, -1, jumpType);
 
-               //2 convert to list of Point
-               point_l = new List<Point>();
+               //2 convert to list of PointF
+               point_l = new List<PointF>();
                 foreach(Jump j in jump_l)
                {
                        DateTime dt = UtilDate.FromFile(j.Datetime);
                        double dtDouble = UtilDate.DateTimeYearDayAsDouble(dt);
 
-                       point_l.Add(new Point(
+                       point_l.Add(new PointF(
                                                dtDouble,
                                                Util.GetHeightInCentimeters(j.Tv)
                                                ));
@@ -62,7 +62,7 @@ public class JumpsEvolution
        public double GetMaxValue()
        {
                double maxValue = 0;
-                foreach(Point p in point_l)
+                foreach(PointF p in point_l)
                {
                        if(p.X > maxValue)
                                maxValue = p.X;
@@ -73,7 +73,7 @@ public class JumpsEvolution
                return maxValue;
        }
 
-       public List<Point> Point_l
+       public List<PointF> Point_l
        {
                get { return point_l; }
        }
diff --git a/src/jumpsWeightFVProfile.cs b/src/jumpsWeightFVProfile.cs
index b57b03d2..da157cfe 100644
--- a/src/jumpsWeightFVProfile.cs
+++ b/src/jumpsWeightFVProfile.cs
@@ -23,7 +23,7 @@ using System.Collections.Generic; //List
 
 public class JumpsWeightFVProfile
 {
-       private List<Point> point_l;
+       private List<PointF> point_l;
        LeastSquaresLine ls;
 
        //constructor
@@ -36,12 +36,12 @@ public class JumpsWeightFVProfile
                //1 get data
                 List<Jump> jump_l = SqliteJump.SelectJumpsWeightFVProfile (personID, sessionID, false); 
//TODO:true);
 
-               //2 convert to list of Point
-               point_l = new List<Point>();
+               //2 convert to list of PointF
+               point_l = new List<PointF>();
                 foreach(Jump j in jump_l)
                {
                        /*
-                       point_l.Add(new Point(
+                       point_l.Add(new PointF(
                                                j.Weight,
                                                Util.GetHeightInCentimeters(j.Tv)
                                                ));
@@ -53,7 +53,7 @@ public class JumpsWeightFVProfile
                        //hp0 = trochanterToe - trochanterFloorOnFlexion
                        double force = (personWeight + j.Weight) * 9.81 * ( ( 
Util.GetHeightInCentimeters(j.Tv) / (trochanterToe - trochanterFloorOnFlexion) ) + 1 );
 
-                       point_l.Add(new Point(
+                       point_l.Add(new PointF(
                                                Util.GetInitialSpeed(j.Tv, true), //TODO: pass 
preferences.metersSecondsPreferred and show it on graph label
                                                force
                                                ));
@@ -70,7 +70,7 @@ public class JumpsWeightFVProfile
        public double GetMaxValue()
        {
                double maxValue = 0;
-                foreach(Point p in point_l)
+                foreach(PointF p in point_l)
                {
                        if(p.X > maxValue)
                                maxValue = p.X;
@@ -81,7 +81,7 @@ public class JumpsWeightFVProfile
                return maxValue;
        }
 
-       public List<Point> Point_l
+       public List<PointF> Point_l
        {
                get { return point_l; }
        }
diff --git a/src/utilMath.cs b/src/utilMath.cs
index edacf592..8cf31110 100644
--- a/src/utilMath.cs
+++ b/src/utilMath.cs
@@ -22,12 +22,13 @@
 using System;
 using System.Collections.Generic; //List<T>
 
-public class Point
+//note this has doubles. For ints can use Gdk.Point
+public class PointF
 {
        private double x;
        private double y;
 
-       public Point(double x, double y) 
+       public PointF(double x, double y)
        {
                this.x = x;
                this.y = y;
@@ -92,12 +93,12 @@ public class LeastSquaresLine
 
        public void Test()
        {
-               List<Point> measures = new List<Point> {
-                       new Point(1, 10.3214), new Point(2, 13.3214), new Point(3, 18.3214) };
+               List<PointF> measures = new List<PointF> {
+                       new PointF(1, 10.3214), new PointF(2, 13.3214), new PointF(3, 18.3214) };
                Calculate(measures);
        }
 
-       public void Calculate(List<Point> measures)
+       public void Calculate(List<PointF> measures)
        {
                int n = measures.Count;
                double sumX = 0; //sumatory of the X values
@@ -106,7 +107,7 @@ public class LeastSquaresLine
                double sumXY = 0; //sumatory of the squared X values
 
                //for(int i = 0; i < numMeasures; i++)
-               foreach(Point p in measures)
+               foreach(PointF p in measures)
                {
                        sumX = sumX + p.X;
                        sumY = sumY + p.Y;
@@ -147,10 +148,10 @@ public class LeastSquaresParabole
 
        public void Test()
        {
-               List<Point> measures = new List<Point> {
-                       new Point(1, 10.3214), new Point(2, 13.3214), new Point(3, 18.3214),
-                           new Point(4, 25.3214), new Point(5, 34.3214), new Point(6, 45.3214), 
-                           new Point(7, 58.3214), new Point(8, 73.3214), new Point(9, 90.3214), new 
Point(10, 109.3214) };
+               List<PointF> measures = new List<PointF> {
+                       new PointF(1, 10.3214), new PointF(2, 13.3214), new PointF(3, 18.3214),
+                           new PointF(4, 25.3214), new PointF(5, 34.3214), new PointF(6, 45.3214),
+                           new PointF(7, 58.3214), new PointF(8, 73.3214), new PointF(9, 90.3214), new 
PointF(10, 109.3214) };
 
                //R testing
                //x=1:10
@@ -159,11 +160,11 @@ public class LeastSquaresParabole
                Calculate(measures);
        }
 
-       public void Calculate(List<Point> measures)
+       public void Calculate(List<PointF> measures)
        {
                /*
                LogB.Information("printing points at Calculate");
-               foreach(Point p in measures)
+               foreach(PointF p in measures)
                        LogB.Information(p.ToString());
                        */
 
@@ -266,5 +267,12 @@ public class LeastSquaresParabole
                        return ParaboleTypes.CONVEX;
                }
        }
+}
 
+public static class MathCJ
+{
+       public static double ToRadians(double angdeg)
+       {
+               return angdeg / 180 * Math.PI;
+       }
 }


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