[chronojump] Added the call to getSprintFrom3Positions



commit 15790325b613889c0b62dd332ce9b4ebc5a8f873
Author: Xavier Padullés <x padulles gmail com>
Date:   Fri Mar 31 11:58:07 2017 +0200

    Added the call to getSprintFrom3Positions

 r-scripts/sprintPhotocells.R |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/r-scripts/sprintPhotocells.R b/r-scripts/sprintPhotocells.R
index c4c6d8d..953c6a7 100644
--- a/r-scripts/sprintPhotocells.R
+++ b/r-scripts/sprintPhotocells.R
@@ -51,11 +51,18 @@ getSprintFromPhotocell <- function(positions, splitTimes, noise=0)
         }
         
         # For the correct calculation we need at least 2 values in the position and time
-        if(length(positions) < 2){
+        if(length(positions) <= 2){
                 print("Not enough data")
                 return()
         }
         
+        #Asuming that the first time and position are 0s it is not necessary to use the non linear regression
+        #if there's only three positions. Substituting x1 = x(t1), and x2 = x(t2) whe have an exact solution.
+        #2 variables (K and Vmax) and 2 equations.
+        if (length(positions == 3)){
+                return(getSprintFrom2SplitTimes(x1 = positions[2], x2 = position[3], t1 = splitTimes[2], t2 
= splitTimes[3] ))
+        }
+        
         photocell = data.frame(time = splitTimes, position = positions)
         
         # Using the model of v = Vmax(1 - exp(-K*t)). If this function are integrated and we calculate the 
integration constant (t=0 -> position = 0)


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