[chronojump] MIF. Clarified the impulse calculation
- From: Xavier Padullés <xpadulles src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] MIF. Clarified the impulse calculation
- Date: Tue, 12 Mar 2019 17:00:43 +0000 (UTC)
commit 2bc799f9e91cf4708a3e2e0c5557ec740a18a859
Author: Xavier Padullés <x padulles gmail com>
Date: Tue Mar 12 17:58:56 2019 +0100
MIF. Clarified the impulse calculation
r-scripts/maximumIsometricForce.R | 41 ++++++++++++++-------------------------
1 file changed, 15 insertions(+), 26 deletions(-)
---
diff --git a/r-scripts/maximumIsometricForce.R b/r-scripts/maximumIsometricForce.R
index 3311754f..cbaeff0d 100644
--- a/r-scripts/maximumIsometricForce.R
+++ b/r-scripts/maximumIsometricForce.R
@@ -281,21 +281,8 @@ drawDynamicsFromLoadCell <- function(
c(dynamics$f.raw[startImpulseSample:endImpulseSample], 0, 0), col = "grey")
#Calculation of the impulse
- #Sum of the area of all the triangles formed with a vertex in the origin and the
other vertex in the
- #n-th and (n+1)-th point of the polygon
- impulse = 0
- for(n in startImpulseSample:(endImpulseSample - 1))
- {
- #Area of the paralelograms, not the triangle
- area = ((dynamics$time[n+1] - dynamics$time[dynamics$startSample]) *
dynamics$f.raw[n] - (dynamics$time[n] - dynamics$time[dynamics$startSample]) * dynamics$f.raw[n+1])
- impulse = impulse + area
- }
-
- area = (dynamics$time[endImpulseSample] - dynamics$time[dynamics$startSample]) *
dynamics$f.raw[endImpulseSample]
- impulse = impulse + area
-
- #Area under the curve is one half of the sum of the area of paralelograms
- impulse = impulse / 2
+ impulse = getAreaUnderCurve(dynamics$time[startImpulseSample:endImpulseSample],
dynamics$f.raw[startImpulseSample:endImpulseSample])
+
} else if(impulseOptions$impulseFunction == "FITTED")
{
impulseColor = "blue"
@@ -309,19 +296,21 @@ drawDynamicsFromLoadCell <- function(
#Calculation of the impulse
#Sum of the area of all the triangles formed with a vertex in the origin and the
other vertex in the
#n-th and (n+1)-th point of the polygon
- impulse = 0
- for(n in startImpulseSample:(endImpulseSample - 1))
- {
- #Area of the paralelograms, not the triangle
- area = ((dynamics$time[n+1] - dynamics$time[dynamics$startSample]) *
dynamics$f.fitted[n] - (dynamics$time[n] - dynamics$time[dynamics$startSample]) * dynamics$f.fitted[n+1])
- impulse = impulse + area
- }
+ # impulse = 0
+ # for(n in startImpulseSample:(endImpulseSample - 1))
+ # {
+ # #Area of the paralelograms, not the triangle
+ # area = ((dynamics$time[n+1] - dynamics$time[dynamics$startSample]) *
dynamics$f.fitted[n] - (dynamics$time[n] - dynamics$time[dynamics$startSample]) * dynamics$f.fitted[n+1])
+ # impulse = impulse + area
+ # }
+ #
+ # area = (dynamics$time[endImpulseSample] - dynamics$time[dynamics$startSample]) *
dynamics$f.fitted[endImpulseSample]
+ # impulse = impulse + area
+ #Area under the curve is one half of the sum of the area of paralelograms
+ #impulse = impulse / 2
+ impulse = getAreaUnderCurve(dynamics$time[startImpulseSample:endImpulseSample],
dynamics$f.fitted[startImpulseSample:endImpulseSample])
- area = (dynamics$time[endImpulseSample] - dynamics$time[dynamics$startSample]) *
dynamics$f.fitted[endImpulseSample]
- impulse = impulse + area
- #Area under the curve is one half of the sum of the area of paralelograms
- impulse = impulse / 2
}
text(x = (dynamics$startTime + (dynamics$time[endImpulseSample] -
dynamics$time[startImpulseSample])*0.66), y = mean(dynamics$f.raw[startImpulseSample:endImpulseSample])*0.66,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]