Created
January 4, 2012 13:43
-
-
Save datablend/1560142 to your computer and use it in GitHub Desktop.
Update average speed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Recalculate average speed | |
double previousspeed = (Double)torecord.getProperty("speed"); | |
int previousoccurences = (Integer)torecord.getProperty("occurences"); | |
double currentspeed = analyzer.getHorizontalSpeed(track.getTrkpt(i).getTime()); | |
double denormalizespeed = previousspeed * previousoccurences; | |
double newspeed = ((denormalizespeed + currentspeed) / (previousoccurences + 1)); | |
// Update the data accordingly | |
torecord.setProperty("speed",newspeed); | |
torecord.setProperty("occurences",previousoccurences+1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment